Simple VisualBasic Referencing Problem

Jon H

New Member
Joined
Nov 23, 2005
Messages
17
Hi,

I have a simple Visual Basic question.

I have created a simple macro to import some data into my spreadsheet. One of the lines in the visual basic specifies to go to a different worksheet. It reads:

Sheets("M3BASE_1").Select

However, instead I would like it to use some text in a cell as the name of the sheet to select. (ie I am going to type the name of the sheet I want the macro to select in a cell, say A1 for instance. I want the macro to look at this cell and use the text to know which sheet to select.)

What command do I replace the above with to get this to work?

Any help greatly appreciated!

Thanks
Jon
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,494
Hi, Welcome to the Board!

Try
Code:
On Error Resume Next
Sheets(Range("A1").Value).Select
On Error GoTo 0

or, more accurately, something like:
Code:
On Error Resume Next
Sheets(Sheets("Sheet1").Range("A1").Value).Select
On Error GoTo 0
 

Watch MrExcel Video

Forum statistics

Threads
1,119,137
Messages
5,576,299
Members
412,716
Latest member
Ardin
Top