ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding worksheets by using variable names (https://www.excelbanter.com/excel-programming/306542-finding-worksheets-using-variable-names.html)

Paul

Finding worksheets by using variable names
 
Hi,

Sheets are named "Jim" "Tom" "Judy" etc. The MASTER sheet
also has these names in a table. I want to click on a cell
containing "Tom" and have the code jump to the Tom sheet.

I tried this:
AAA=Activecell.value ' the cell contains word "Tom"
Sheets(AAA).select 'should find Tom sheet

But I get an error message, probably because VB is
expecting the AAA to be in quotes, and it's no recognizig
that AAA is a variable value.

Help appreciated
Paul



Harald Staff

Finding worksheets by using variable names
 
Hi Paul

With a sheet named Tom this worked fine he

Sub test()
Dim AAA As String
AAA = "Tom"
Sheets(AAA).Select
End Sub

But I get an error message, probably because VB is
expecting the AAA to be in quotes


No. What did the message actually say ?

Best wishes Harald

"Paul" skrev i melding
...
Hi,

Sheets are named "Jim" "Tom" "Judy" etc. The MASTER sheet
also has these names in a table. I want to click on a cell
containing "Tom" and have the code jump to the Tom sheet.

I tried this:
AAA=Activecell.value ' the cell contains word "Tom"
Sheets(AAA).select 'should find Tom sheet

But I get an error message, probably because VB is
expecting the AAA to be in quotes, and it's no recognizig
that AAA is a variable value.

Help appreciated
Paul






All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com