VBA code that moves to a variable address that is contained in an ADDRESS formula

Copper Contributor

I have cell (say C1) that contains an exact address (say $F$20 for example) using the ADDRESS function.  

I would like VBA code to move the cursor to that address.  

But each time the VBA code is utilized, the value in cell C1 changes to a new Address.  (say $z$25 the next time), and I would like it to automatically move to the new address contained in cell C1 each time.  

When I try to record a macro using FIND or GOTO from the pull down menu, it only keeps the first address value ever used.  It never updates to the new address.   

Does anyone know how to do this. 



4 Replies


How about

Sub MoveToCell()
End Sub
best response confirmed by Hans Vogelaar (MVP)


To move the cursor to the address contained in cell C1, you can use the Range object in VBA. Since the value in cell C1 changes dynamically, you need to read the value from cell C1 each time the VBA code is executed.
Here is an example VBA code that moves the cursor to the address in cell C1:


Sub MoveToAddress()
    Dim address As String
    address = Range("C1").Value ' Read the address from cell C1
    Range(address).Select ' Move to the address
End Sub


In this code, the Range("C1").Value statement retrieves the value (address) from cell C1, and then the Range(address).Select statement selects that range, effectively moving the cursor to that address.
You can run the MoveToAddress macro each time you want to move the cursor to the updated address in cell C1.

I'm glad that they were helped.
I wish you continued success with Excel!