Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 24th, 2011, 02:00 PM
Registered User
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation How to navigate back to a cell ?

I have a Excel 2007 VBA routine which stores the active cell reference using ;

CellLocation = ActiveCell.Address

My routine then goes off and performs various tasks which moves the active range.

After these tasks are complete, I want to navigate back to the original CellLocation.

However, I cant workout the syntax to go back to select the cell contained in "CellLocation"

Can anyone help ?

And should I declare the CellLocation variable as a particular type ?

many thanks in advance,
Old November 26th, 2011, 01:48 AM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts


You can try using Select like this
Dim InitCellLocation as Range
Set InitCellLocation = ActiveCell
' --- your code here 
' -- end of code
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Old November 28th, 2011, 04:08 PM
JP JP is offline
Authorized User
Join Date: Apr 2008
Posts: 57
Thanks: 1
Thanked 3 Times in 3 Posts

Since the Range.Address Property returns a String type, you should declare CellLocation as a String:

Dim CellLocation As String
Then after assigning the ActiveCell.Address to CellLocation and running the rest of your code, use

at the end.
JP SoftTech

Similar Threads
Thread Thread Starter Forum Replies Last Post
back color of cell of datagrid [email protected] VB.NET 1 November 18th, 2006 03:28 AM
Navigate through nodes abelmirma XML 1 May 7th, 2005 07:32 AM
Navigate through Datagrid Abhinav_jain_mca General .NET 2 September 8th, 2004 01:10 AM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM
How to navigate alyeng2000 ADO.NET 1 December 8th, 2003 10:26 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.