Share via

Target Address

Anonymous
2012-03-20T16:14:50+00:00

I have an address listed in cell C1 (ex. E6).  I would like some vba that would select that cell stated in C1.  So everytime the target address in C1 changes that cell address will be selected.

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-03-20T19:48:05+00:00

I have formulas that chang the "cell reference" in cell C1.  Basically I want code to run that will check the cell location stated in C1 and select that cell.  It doesn't need to see that the cell has changed, just look at cell C1 when the code runs.

 

Thanks

Hi,

Either of these 2 lines in your code will read c1 and select the addres of the text in that cell

Application.Goto Range(Range("C1").Text)

Range(Range("C1").Text).Select

Unless you are very confident that C1 will always contain a valid address you should wrap either of the above lines with

on error resume next

on error goto 0

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2012-03-20T17:18:26+00:00

    I have code that would trigger that part.  I would like for it to go in my regular module and I can call it from within there.

    Thanks

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-03-20T17:11:46+00:00

    Thanks, is there anyway to put this code in a module and not the sheet object?

     

    It could be re-written to go in a general module but if you want it to run automatically then we would still need to use the change event to call it.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-03-20T16:50:46+00:00

    Thanks, is there anyway to put this code in a module and not the sheet object?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-03-20T16:29:52+00:00

    Hi,

    Right click the sheet tab, view code and paste this in

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub

    If Target.Address = "$C$1" Then

    Application.EnableEvents = False

    On Error Resume Next

    Range(Target.Text).Select

    On Error GoTo 0

    Application.EnableEvents = True

    End If

    End Sub

    Was this answer helpful?

    0 comments No comments