A
aelbob
Objective : An Excel macro that will select (goto) a range specified by
the current active cell, which the user selects from a list of range names
prior to invoking the macro. I found code on the web that will work when the
active cell contains the range in address format (e.g., $A10:$B100), but
not when the content of the active cell is the range name proper (e.g.,
the_goto_range). Using Excel functions in the worksheet, I can create
a list of range addresses in a column next to a column list of range names,
and then use the macro below by selecting the range address for the
desired range to goto -- but shouldn't I be able to get a string range name
into the VBA "Set " range and "Application.Goto Reference:=" statements?
Thanks for any ideas.
Sub go_to_range()
' this macro selects the range indicated by the active cell value
' BUT the active cell range format must be sheet!colrow:colrow --
' range names in active cell do not work !!
Dim SH As Worksheet
Dim arr As Variant
Dim rng As Range
arr = Split(ActiveCell.Value, "!")
' the split function parses the active cell value based on the indicated
delimiter
' (which must be entered in quote marks) & creates a string array
Set SH = Sheets(arr(0))
Set rng = SH.Range(arr(1))
Application.Goto Reference:=rng
End Sub
the current active cell, which the user selects from a list of range names
prior to invoking the macro. I found code on the web that will work when the
active cell contains the range in address format (e.g., $A10:$B100), but
not when the content of the active cell is the range name proper (e.g.,
the_goto_range). Using Excel functions in the worksheet, I can create
a list of range addresses in a column next to a column list of range names,
and then use the macro below by selecting the range address for the
desired range to goto -- but shouldn't I be able to get a string range name
into the VBA "Set " range and "Application.Goto Reference:=" statements?
Thanks for any ideas.
Sub go_to_range()
' this macro selects the range indicated by the active cell value
' BUT the active cell range format must be sheet!colrow:colrow --
' range names in active cell do not work !!
Dim SH As Worksheet
Dim arr As Variant
Dim rng As Range
arr = Split(ActiveCell.Value, "!")
' the split function parses the active cell value based on the indicated
delimiter
' (which must be entered in quote marks) & creates a string array
Set SH = Sheets(arr(0))
Set rng = SH.Range(arr(1))
Application.Goto Reference:=rng
End Sub