sheets.select with reference to Cells value

  • Thread starter Thread starter mooky104
  • Start date Start date
M

mooky104

Hi,

I am designing vba macro where i have to select a particular sheets
depending of name in a cell ("A12").

"A12" value is always a text. its value change from day to day.
The sheet with "A12" value as name does exist in the workbook

I tried this macro based on the newsgroup archives, but it copies A12
value on "index" sheets rather than "A12" name sheet.
Any idea how to select this sheet?


Sub test()

Dim i As Integer
Sheets("index").Select
namsh = Range("A12").Value

For i = 1 To Sheets.Count
If Sheets(i).Name = namsh Then
Sheets(i).Select
End If
Next i

Range("I1").Value = namsh

End Sub
 
Sub test()

Dim i As Integer
Sheets("index").Select
namsh = Range("A12").Value

For i = 1 To Sheets.Count
If Sheets(i).Name = namsh Then
Sheets(i).Range("I1").Value = namsh
Exit For
End If
Next i



End Sub
 
Thanks ;-))

I am so stupid. i came to realise that it was B12 instead of A12 so
obviously it could not find any sheet.
lost 1h15 on that .... luckyly, it is friday evening ;-))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top