Quick Question: How to come back to original cell location?

Almost done with my macro! :)

Initially, I place my curse in a location. And after a few 
moves around the macro (Hard coded and Offsets) I want to 
return back to the original location where I initially 
placed my curser.

Any help is apprectiated!!  
0
John1063 (943)
8/18/2004 9:22:39 PM
excel.misc 78881 articles. 5 followers. Follow

4 Replies
510 Views

Similar Articles

[PageSpeed] 9

Hi
normally no need for selections within your macro (you may post your
code for 'correction'). But if you want to store the original active
cell try:

sub foo()
dim wks as worksheet
dim rng as range
set wks = activesheet
set rng=wks.activecell
'your code
wks.activate
rng.select
end sub

--
Regards
Frank Kabel
Frankfurt, Germany

"John" <John@discussions.microsoft.com> schrieb im Newsbeitrag
news:86d001c48569$7d596f50$a501280a@phx.gbl...
> Almost done with my macro! :)
>
> Initially, I place my curse in a location. And after a few
> moves around the macro (Hard coded and Offsets) I want to
> return back to the original location where I initially
> placed my curser.
>
> Any help is apprectiated!!

0
frank.kabel (11126)
8/18/2004 9:28:51 PM
The easiest way is to save the initial cell in a range variable:


    Dim rOldActiveCell As Range
    Set rOldActiveCell = ActiveCell

    'your code here

    Application.GoTo rOldActiveCell


However, the *best* way to do this is to never "move" the active cell. 
Instead of using Select/Activate, use the Range objects directly. For 
example, instead of


    ActiveCell.Offset(1, 0).Select
    ActiveCell.Copy
    ActiveCell.Offset(0, 5).Select
    ActiveCell.PasteSpecial Paste:=xlValues
    

use:

    ActiveCell.Offset(1, 5).Value = ActiveCell.Offset(1, 0).Value

or, slightly more efficiently:

    With ActiveCell
        .Offset(1, 5).Value = .Offset(1, 0).Value
    End With





In article <86d001c48569$7d596f50$a501280a@phx.gbl>,
 "John" <John@discussions.microsoft.com> wrote:

> Almost done with my macro! :)
> 
> Initially, I place my curse in a location. And after a few 
> moves around the macro (Hard coded and Offsets) I want to 
> return back to the original location where I initially 
> placed my curser.
> 
> Any help is apprectiated!!
0
jemcgimpsey (6723)
8/18/2004 9:35:29 PM
Awesome!  Thanks!


>-----Original Message-----
>The easiest way is to save the initial cell in a range 
variable:
>
>
>    Dim rOldActiveCell As Range
>    Set rOldActiveCell = ActiveCell
>
>    'your code here
>
>    Application.GoTo rOldActiveCell
>
>
>However, the *best* way to do this is to never "move" the 
active cell. 
>Instead of using Select/Activate, use the Range objects 
directly. For 
>example, instead of
>
>
>    ActiveCell.Offset(1, 0).Select
>    ActiveCell.Copy
>    ActiveCell.Offset(0, 5).Select
>    ActiveCell.PasteSpecial Paste:=xlValues
>    
>
>use:
>
>    ActiveCell.Offset(1, 5).Value = ActiveCell.Offset(1, 
0).Value
>
>or, slightly more efficiently:
>
>    With ActiveCell
>        .Offset(1, 5).Value = .Offset(1, 0).Value
>    End With
>
>
>
>
>
>In article <86d001c48569$7d596f50$a501280a@phx.gbl>,
> "John" <John@discussions.microsoft.com> wrote:
>
>> Almost done with my macro! :)
>> 
>> Initially, I place my curse in a location. And after a 
few 
>> moves around the macro (Hard coded and Offsets) I want 
to 
>> return back to the original location where I initially 
>> placed my curser.
>> 
>> Any help is apprectiated!!
>.
>
0
anonymous (74722)
8/18/2004 9:57:28 PM
dim CurCell as range
set curCell = Activecell
''''
application.goto curcell ', scroll:=true

But it's pretty unusual to actually have to select other cells.  Maybe you could
just work on them directly:

mycell.offset(1,3).value = "abcde"

Instead of selecting first.



John wrote:
> 
> Almost done with my macro! :)
> 
> Initially, I place my curse in a location. And after a few
> moves around the macro (Hard coded and Offsets) I want to
> return back to the original location where I initially
> placed my curser.
> 
> Any help is apprectiated!!

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10082)
8/18/2004 10:08:30 PM
Reply:

Similar Artilces:

question on reassigning account
When we reassign account, the new owner gets ownership of all the open items underneath the accounts. (For example, the Cases for the account!). Is there a way to change the ownership for accounts without affecting the ownership of the child records? There isn't any way to avoid this in the current version. -- Matt Wittemann http://icu-mscrm.blogspot.com "smitzer" wrote: > When we reassign account, the new owner gets ownership of all the open items > underneath the accounts. (For example, the Cases for the account!). Is there > a way to change the ownership for...

Mark back ordered items on purchase orders.
My customer is looking for a way to mark on a purchase order when an item has been back ordered by her supplier. A check box or note box on each line of the PO would be great. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/...

A few questions
Hi, I am trying to automate a few tasks at work and would like to get Excel to do a few different things. I am new to excel programming, so if someone could just give me a shove in the right direction I'd appreciate it. When we open a workbook I would like to always have it open to a "Main Menu" area. Then I would like to be able to choose "P" for payroll and the correct sheet would open. I also would like to be able to automate inserting a blank payroll sheet into the active sheet. So I think it would go like this... I would finish with this weeks data entry are...

Merged cells.
Hi, Please can someone help me in regards to a merged cell difficulty. When I type a couple of lines of text into a merged cell, I find that a couple of things do not happen. First of all I notice that if I do not have wrap text on, the text does not extend into the next cell. Secondly, when I do have wrap text on, and type in several lines of text, the row height does not automatically grow to accomodate the lines of text. I am left to do this manually which is not as satisfactory. Can anyone comment on these differences between normal and merged cells. Regards, David Thomas. Melbourne. T...

Select a certain number of cells in a row
Hi, I'd like to have the macro to select row 5 to 10 in the active column. May I know what is the VB code to write? Regards, Valerie maybe... dim myRng as range dim myCol as long with activesheet mycol = activecell.Column set myrng = .range(.cells(5,mycol),.cells(10,mycol)) end with myrng.select ======= or with activesheet .cells(5,activecell.column).resize(6).select end with I'm not quite sure why you want to select that range. But for the most part, if you act directly on the range (and avoid .selects), you're code will work faster and be easier to modify. Dolph...

Create a 3rd sheet containing cells in both Sheets 1 and 2
I have 2 sheets. They both contain a list of Account Numbers. What I want to do is to have a 3rd sheet created containing only those account numbers that are found in both Sheet 1 and Sheet 2. For example: Sheet 1 Account Numbers AAAAA BBBBB CCCCC DDDDD EEEEE FFFFFF 9999999 GGGGGG HHHHHH IIIIIII JJJJJJ KKKKKK LLLLLLL 333333 444444 Sheet 2 Account Numbers 1111111 KKKKKKK 222222 EEEEEEE 999999 XXXXXXX TTTTTTTT AAAAAA FFFFFFFF Sheet 3 AAAAAAA EEEEEEEE FFFFFFF 9999999 KKKKKKKK By the way, I am a REAL BIG beginner with excel, so please provide some...

lookup question
I am having trouble figuring out how to look something up in a list based on conditions. For example I have: Store # State Open Date 1 ND 1/2/03 2 SD 2/4/03 in a list with approx 350 records which all have this same info. I need to create another table that shows which stores opened in which state in each month. So, I need to say if the open date is in January (or between Jan 1 & Jan 31) & the state is ND then I need the cell the formula is in to read 1. Basically if the op...

"Reply" cursor default location
Something changed just yesterday that is driving me crazy. I accept that I must have done something to cuase this (hitting some sequence of keys perhaps), but I have no idea how to fix it. When any of us receive an email from a sender and elect to respond to it by clicking on the "reply" button, what happens to me now is that my cursor defaults to the address "To:" box in the new reply message rather than the message content area where I would typically just be able to start printing my reply message. Needless to say, I start typing away, galnce up at the scree...

Quick help with excel formula
Ok, i need a forumla. this is what I want, i have two columns like this Time Start: ............. Time Finish: ............ I fill out these two columns like this Time Start: ...17:42... Time Finish: ...18:25.. Now i have another Column that says Training Length: ........ I want this to work out the time between 17:42 and 18:25 Any one help pleas -- Message posted from http://www.ExcelForum.com Hi simply =A2-A1 and format as time If your training time can span midnight use the formula =A2-A1+(A2<A1) >-----Original Message----- >Ok, i need a forumla. > >this is what ...

Back to CDialog from child window ?
Hi, I created a dialog app and derived a class from CEdit and made it a member (child?) of CDialog named CClientDlg In the derived class in override OnChar(). From the OnChar() i want to call a method of the dialog. How do i do this ? How do you get from a child window to the parent window. I have tried something like : ((CClientDlg*)GetParent())->Test() The method shows up in the codecompletion window, but the CClientDlg is not known. Till now i always used messaging to get back to the main window. (!?) RAN wrote: > Hi, > > I created a dialog app and derived a class from...

Chart question
I am trying to make a chart that shows 2009 numbers versus 2008 numbers and here is my issue: I have 4 cities Chicago(A1), Dallas(A2), Detroit(A3), and Los Angeles(A4) that I have for 2008 and 2009 but I added 2 cities for 2009. Is there a way to do a vlookup to pull the data for the chart or do I have to set up the data sheets the same way...I tried to make this short so sorry if its not enough info, just let me know if I can clear something up. Thanks in advance You should put your new cities in A5 and A6 (just their names --- <grin>) In B5 and B6 enter =NA() which wil...

Copying certain column information quickly
As you know in Excel you could quickly copy the information you needed with a drag of the mouse. Because I need information copied repeatedly and easily for my access unfirmiliar co workers. Example JOB CUSTOMER QUOTE # A B1 110701 A(copied) A2 110701 (copied) A(copied) C4 110701 (copied) How do I do this quickly and efficiently for the computer challenged. Sorry, Access is a database, not a spreadsheet, and can't be used like one. You can write some code to select the rows that you want to ...

Delete cell and move to next
Hi all Can anyone help with a macro. It is supposed to check if the cell in column A is empty and if it is delete and move the contents of B into A on deletion. I would post my workings but am too ashamed to do so. Please help. Rob Rob, Not sure if you mean any cell in column A, and by move whether you want to shift everything over. You could use: Sub Macro1() On Error Resume Next Columns("A:A").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft End Sub which would do all cells at once, and shift everything over by one cell whereever there is a blank. If it is just a few c...

POP3 Switching back to localhost in OL2003
I have tried to set the POP3 server in an email account to ipostoffice.worldnet.att.net but if I reboot it changes to localhost and I have to go back into Controlpanel/mail or the accounts setup in Outlook to correct it. This is your antivirus software's doing - check with their support to see if they have a newer version that handles mail scanning in a more sophisticated fashion. Don't just disable mail scanning - best to have more than one layer of defense. Jim Hunter wrote: > I have tried to set the POP3 server in an email account to > ipostoffice.worldnet.att.net but if I...

Event Sounds Question
I assign wav files to system events. Certain ones won't play when when I assign it to the Windows Logon event. It previews fine and plays in Windows Media Player I thought the length was the problem 'cause these wav files are 22 and 24 seconds but I assigned a wav file to the Windows Logon that is 30 seconds and it plays fine. Although the length does have an impact. Any ideas?? James ...

Seperate text into two cells
I have a large phone list excel worksheet with each person's first and last name in one cell seperated by a space. How can I quickly seperate the name into two cells (first name and last name) so I can import into a database? Otherwise, I need to cut and paste the entire list. Data>Text to Columns, choose "delimited" and check the space character as separator -- Kind Regards, Niek Otten Microsoft MVP - Excel "JeffK" <JeffK@discussions.microsoft.com> wrote in message news:C074D3E2-5EC6-4E25-970D-0F4FEAF5AB79@microsoft.com... >I have a large phon...

Powerpoint slideshow in assigned screen location..
I need to show powerpoint slideshows inside my VC++/MFC window. I tried implementing VB code given in http://skp.mvps.org/vb/pptvbwnd.htm in VC++, however, even though i set ShowType to '1' (ppshowTypeSpeaker), a slideshow in full screen is being opened when i call SlideshowSettings.Run(). Its not allowed by my client. Iam using Office 2007. Is it is possible with powerpoint viewe?. Is there any way to show slideshow in assigned location on our own window using PowerPoint Viewer?? Since new powerpoint viewers don't support automation, i tried using CreateProcess() AP...

Quick Question
I have been using Office 2007 and OneNote for some time now and have recently set up the 2010 Beta on a second system. In the 2007 version there was a way to repair office if things went flaqky. How do I do that in Office 2010? Michael On Tue, 8 Dec 2009 23:59:26 +0000 (UTC), Rev. Michael L. Burns <sdbpastor@charter.bet> wrote: > >I have been using Office 2007 and OneNote for some time now and have recently >set up the 2010 Beta on a second system. In the 2007 version there was a >way to repair office if things went flaqky. How do I do that in Office 2...

License Question
I know a user needs a license to the Sales module to see it in CRM client, but does a user need a Sales License to use CRM Sales For Outlook? Or will just a standard license do? Anybody know? From what I have read in the IG the license you pruchase for the Sales (or Customer Service) module will entitle you to use both the web browser interface and/or the Outlook client interface with no additional cost. Panayiotis On Thu, 15 Apr 2004 10:01:10 -0700, Heather Bain <anonymous@discussions.microsoft.com> wrote: >I know a user needs a license to the Sales module to see it in CRM cl...

Is there a quick way to...
highlighting only the odd or even numbered rows? Thanks. Something like this should do: Sub banding() ActiveSheet.Range("A65536").Select Selection.End(xlUp).Select lastrow = ActiveCell.Row Range("A6:AK" & lastrow).Select Selection.Interior.ColorIndex = xlNone 'Change rownum to the the first row number where data occurs rownum = 6 For i = 1 To (lastrow - rownum) Step 2 Range("B" & rownum + i & ":AK" & rownum + i).Select With Selection.Interior .ColorIndex = 15 .Pattern = xlSolid End With ...

Clipboard question... CF_...what?
Hi, I understand this information is all out there, but it's all a bit confusing and I never know for sure when I read about it... I had a non-Unicode application and copied/pasted to/from the clipboard through CF_TEXT which went all fine. Now I moved to Unicode and need to update my copy/paste routines. I implemented copy and paste for CF_UNICODETEXT. But I have some questions: 1. When I look in the DataObject Viewer I sometimes see only CF_OEMTEXT and CF_TEXT on the clipboard (depending what the source was), but when I paste this contents in my application, I handle it through GetCl...

Newbi MFC Dialog question
Lets say I have dialog A. On dialog A, I have a button that opens Dialog B. I want to be able to set the control values of a combo box of values from Dialog A. I tried setting them before the doModal(), but I keep getting assertion errors. emailDLG dlg; CComboBox* test = (CComboBox*)dlg.GetDlgItem(IDC_TESTBOX); test->AddString("test1"): test->AddString("test2"): if (dlg.DoModal() !=IDCANCEL) { .. .... ...... Thanks in advance! Scott Hi, First, your probably not familiar with Control variables. http://www.flounder.com/getdlgitem.htm I have not used GetDlgI...

Quick campaign- change to all quick campaigns
Does any one know how to set the following to default. In the quick campaign view, change 'my quick campaigns' to 'all quick campaigns' Cheers Sid ...

Time Series Question
I have a line graph depicting product tests over a 2 week period. The Y axis are the results ranging from -10 to +10. The X axis is timescale. The problem I have is that the timescale only allows days, months and years. What I actually need is the x axis to breakdown into hours as multiple tests take place each hour. Is there any way that such can be accomplished in Excel? Regards Daz Use an XY chart, not what is confusing called a line chart. You can then set the X axis increment in Excel's time format. -- David Biddulph "news.microsoft.com" <Post2Group@Only....

Quick Part
When i add a new custom field E.g {DOCPROPERTY "Transaction Comments" }to my document (Type: Text) there is a restriction to 255 characters. Is there any way to increase this? Or is this a M/S word restriction that cannot be changed? Catherine wrote: > When i add a new custom field E.g {DOCPROPERTY "Transaction > Comments" }to my document (Type: Text) there is a restriction to 255 > characters. > Is there any way to increase this? Or is this a M/S word restriction > that cannot be changed? It is a restriction that can't be changed. I d...