How to return to selected cell?

  • Thread starter Thread starter milt
  • Start date Start date
M

milt

I want to write a macro in VBA such that when a user selects a cell on a
worksheet the macro will run, do stuff, and then return to the cell selected
by the user. What I can't figure out is how to return to the cell selected
by the user. This is probably simple but I'm rather new to VBA and would
very much appreciate some help.

Milt
 
Hi
try something like

sub foo()
dim rng as range
set rng = selection
'...
'insert your code
'...
rng.select
end sub
 
Save the cell, and then just re-activate

Set oHere = Activecell

' do some stiff

oHere.Select

You may need to cater for worksheets also changing.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top