Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Reading Cell Address in VBA

OS: MS Xp
Excel 2003

I am in say cell E127 and need t go to cell B2. I then need to return to
cell E127.
Problem is E127 is different each time. How do I read the cell address in
VBA so that I may return to it?
Thanks in advanced.
--
Richard
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default Reading Cell Address in VBA

Declare a range object variable:
Dim StartCell as Range

When you need to remember the current active cell's address:
Set StartCell = ActiveCell

When you want to return to that cell later:
StartCell.Activate

At the end of your macro, add:
Set StartCell = Nothing

Hope this helps,

Hutch

"Richard" wrote:

OS: MS Xp
Excel 2003

I am in say cell E127 and need t go to cell B2. I then need to return to
cell E127.
Problem is E127 is different each time. How do I read the cell address in
VBA so that I may return to it?
Thanks in advanced.
--
Richard

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Reading Cell Address in VBA


something like this...

Dim rngFirstCell as Range, rngSecondCell as Range
Set rngFirstCell = ActiveCell 'Assuming E127 is the active cell here
Set rngSecondCell = Cells(2,2) 'i.e. B2

'---
'Code that does something to rngSecondCell
'---

rngFirstCell.Activate 'Go back to e127

On Apr 15, 1:16 pm, Richard wrote:
OS: MS Xp
Excel 2003

I am in say cell E127 and need t go to cell B2. I then need to return to
cell E127.
Problem is E127 is different each time. How do I read the cell address in
VBA so that I may return to it?
Thanks in advanced.
--
Richard


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
reading a blank cell as zero Dana Stricker Excel Discussion (Misc queries) 5 March 13th 08 06:01 PM
Reading the Latest Value into a cell lee Excel Worksheet Functions 1 October 26th 06 03:15 AM
Reading a cell in VBA Ruatha New Users to Excel 3 June 11th 06 04:01 PM
Reading last cell jackh7777777 Excel Discussion (Misc queries) 2 May 26th 06 01:28 AM
Reading formulae in a different cell Albert Excel Discussion (Misc queries) 3 May 5th 06 10:42 AM


All times are GMT +1. The time now is 08:50 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"