How can I specify which cell has focus?

  • Thread starter Christian Blackburn
  • Start date
C

Christian Blackburn

Hi Gang,

I would like to programmatically advance to a specific cell. Can
someone reply with an example?

Thanks,
Christian Blackburn
 
B

Bob Phillips

Application.Goto worksheets("Sheet2").Range("E5")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
T

Tom Ogilvy

Activecell is the currenlty active cell. to make a cell the activecell

Range("B9").Active - this does not change the selection if B9 is within the
current selection - it just activates B9 within the select. Otherwise, it
selects B9

Range("B9").Select - B9 is now both the activecell and the current
selection.

This is done on that activesheet. If you want to go to another sheet,
activate that sheet first

Worksheets("Sheet2").Activate

Range("B9").Select
 
D

Dennis

To go to Cell B9 on a worksheet called Source use this code in the relevant
place

Me.Sheets("Source").Select
Me.ActiveSheet.Range("B9").Select
 
T

Tim Zych

Range("D2000").Select

or

Application.Goto Range("D2000"), True
will scroll D2000 to the upper left of the window (the True part)

Application.GoTo handles book/sheet activation automatically, where as the
selection does not. When using Select, you must first select the workbook
(if it's not active), then the worksheet, then the range, e.g.

Workbooks("Book2").Activate
Worksheets("Sheet1").Select
Range("D2000").Select

whereas GoTo can do it in one line of code:
Application.Goto Workbooks("Book2").Worksheets("Sheet1").Range("D2000"),
True
 
C

Christian Blackburn

Hi Guys,

Thank you all for your help. I didn't even know that you could
specify a range without doing "A6:A6" so that's great. I also
appreciate all the help regarding the need to specify the correct
sheet. Fortunately, right now I have only one sheet, although I get
that I still need to specify it to avoid coding bugs in the future.

Thank you all very much,
Christian Blackburn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top