macro - range name to reference contents of another cell

fulmar57

New Member
Joined
Mar 10, 2019
Messages
8
Hi

In this macro line, Application.Goto Reference:="rangename"

I need the "rangename" to be given by the contents of another cell eg A1, because it will change

I'm sure it's simple - but not to me. Thanks for your help.

M
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

paldob

New Member
Joined
Apr 23, 2018
Messages
28
For named ranges I find it is best to store an additional sheet within the workbook. 3 columns (name of range, sheet name, description)

That way you can find the exact range and sheet. Something like below

Code:
Dim NamedRange As String, WorksheetName as String
Dim Fnd As Range, Rng As Range

   NamedRange = Sheets(xxx).Cells(1,1).Value
   Set Fnd = Sheets("NamedRangeInfo").Range("A:A").Find(NamedRange, , , xlWhole, , , False, , False)

   If Fnd Is Nothing Then
     MsgBox "Unable to Find Named Range in the information sheet", vbinformation, "Error..."
     Exit Sub
   Else
     WorksheetName = Fnd.Offset(0,1).Value
   End If

   Set Rng = ThisWorkbook.Sheets(WorksheetName).Range(NamedRange)

   Application.Goto Reference:= Rng
  
   Set Rng = Nothing
   Set Fnd = Nothing
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,575
Office Version
  1. 365
Platform
  1. Windows
Try:
Code:
 Application.Goto Reference:=Range("A1").Value
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,336
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Deleted as over complicating it, the previous post from Akuini works fine for me.
 
Last edited:

fulmar57

New Member
Joined
Mar 10, 2019
Messages
8
Actually I have another related question...
That solution worked fine where the range name contained the location as a range name. But I also want to make the macro select a cell (ie go to that cell), where the cell address (eg C45) is given by the content of another cell. The content varies.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,426
Messages
5,528,690
Members
409,830
Latest member
KT50

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top