![]() |
How to return to selected cell?
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 -- ---------------------------------------------------- This mailbox protected from junk email by Matador from MailFrontier, Inc. http://info.mailfrontier.com |
How to return to selected cell?
Hi
try something like sub foo() dim rng as range set rng = selection '... 'insert your code '... rng.select end sub -- Regards Frank Kabel Frankfurt, Germany milt wrote: 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 |
How to return to selected cell?
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) "milt" wrote in message news:gCxYb.340515$xy6.1683627@attbi_s02... 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 -- ---------------------------------------------------- This mailbox protected from junk email by Matador from MailFrontier, Inc. http://info.mailfrontier.com |
All times are GMT +1. The time now is 02:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com