opening a worksheet with a cell highlighted

fry

Active Member
Joined
Apr 25, 2007
Messages
411
Hi All

I've just tried to use "range(A1).select" to place the cursor on "A1" whenever the worksheet is selected but it's not working.

I placed the code in the worksheet section but I'm obviously missing something.................HELP!! :)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Did you put it under the Worksheet_Activate event?
Code:
Private Sub Worksheet_Activate()
Range("A1").Select
End Sub
 

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hi Lewiy :)

One day i will get to answer one of these questions before the experts :biggrin:

Leading on from this, what if i wanted to activate the next empty cell of a column, say Column A....

I have this (Figured out all by myself a great achievement for me)

Code:
Private Sub Worksheet_Activate()
Range("A:A").End(xlDown).Offset(1, 0).Select
End Sub

Is this okay or is there a better way, it works fine.....Im just in learning mode!

Thanks!
 

fry

Active Member
Joined
Apr 25, 2007
Messages
411
Thanks Lewiy, where would I put this so that it worked on all sheets in a workbook. I've tried it in "This Workbook" but it doesn't seem to work?? :(
 

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
One day i will get to answer one of these questions before the experts

:LOL: I'd hardly call myself an expert!!

As to your question, your method will work fine as long as there are no blank cells in the middle of column A. Personally I would use:
Code:
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select

The only difference is that I’m using Cell(row,column) notation instead of Range to select the very bottom cell in column A ($A$65536) and then using xlUp rather than xlDown to bring it up to the last non-blank cell in the column.
 

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Thanks Lewiy, where would I put this so that it worked on all sheets in a workbook. I've tried it in "This Workbook" but it doesn't seem to work?? :(

Unfortunately, you would need to actually add it into the code for each sheet seperately. Shouldn't take too long with copy and paste (unless you have hundreds of worksheets)
 

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
edit

Thanks Lewiy....Why use up and not down.....?

Fry, you will need to paste the code in the sheet module.....

Right click sheet name tab click view code and paste in there.
repeat for each sheet tab.

Edit***you answered my question in previous post....."Incase there are blanks in between rows"

Thanks Lewiy
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Thanks Lewiy, where would I put this so that it worked on all sheets in a workbook. I've tried it in "This Workbook" but it doesn't seem to work?? :(

Try in This Workbook

Code:
Private Sub Workbook_SheetActivate(ByVal sh As Object)
Application.Goto reference:=sh.Range("A1"), scroll:=True
End Sub
 

Forum statistics

Threads
1,181,363
Messages
5,929,538
Members
436,676
Latest member
Mavri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top