Active Cell

Nigel Martin

Board Regular
Joined
Feb 17, 2002
Messages
133
Dave Hawley - You may recall you helped me with this:
Hi Nigel

assumming you know how to select a cell with VBA place this in the Private Module of the Sheet concerned. Right click on the sheet name tab and select "View Code"

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.MoveAfterReturn = Not IsEmpty(Target.Value)
End If
End Sub

As you can see it assumes your cell is A1

Trouble I do not know how to select a cell in VBA (fairly new to this VBA game - still learning).
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi Nigel


To select a cell in VBA you would use:

Range("A1").select
or
Cell(1,1).Select

These are for the activesheet only. If on another sheet the easiest way is:

Application.Goto Sheets("Sheet1").Range("A1"), True

The True after the GoTo reference will place the selected cell in the top left of your screen.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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
Back
Top