Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
return the row of any selected cell kim55 Excel Discussion (Misc queries) 3 November 15th 09 06:29 PM
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
Return value(s) based on selected checkboxes Nikki Excel Worksheet Functions 5 May 7th 07 03:48 PM
Inputbox used to return value of selected cell D.S.[_2_] Excel Programming 5 October 25th 03 06:53 PM
Inputbox to return address of cell selected by mouse D.S.[_2_] Excel Programming 2 October 25th 03 06:48 PM


All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"