Home |
Search |
Today's Posts |
#13
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Got it. thanks much again.
"Dave Peterson" wrote: I was just commenting on ghdiez's first suggestion. I didn't mean to suggest that his second suggestion would do what you wanted. I would loop through the sheets using the code that I previously posted. rk0909 wrote: Dave. somehow this does not work. "Sheet" & n does not work at all. If I use Sheets(n). It refers to sheet tab name instead of code name. Any suggestions will be appreciated. RK "Dave Peterson" wrote: Just a note about your first suggestion: 1. wks = "sheet" & Trim(Str(n)) The Str function actually introduces that space character. wks = "Sheet" & n would would nicely--it wouldn't include any spaces. wrote: On 4 sep, 10:06, rk0909 wrote: All, I am trying to use the code name of sheets instead of the tab name, but it wouldn't work for me. Any help will be appreciated. Thanks much, RK Sub test() Dim n As Integer n = 1 wks = "sheet" & n wks.Select End Sub Hi Rk: You need to do some changes: 1. wks = "sheet" & Trim(Str(n)) This, becuase the n variable is numeric (integer) and the string representation has a space at left. You should remove the space. 2. Worksheets(wks).Select The reason is that wks is a string variable, not an object. You pass the sheet name (the value of wks variable) to the Worksheets collection. -- Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
code does not work anymore | Excel Discussion (Misc queries) | |||
Event code won't work | Excel Discussion (Misc queries) | |||
Why this code is not work? | Excel Worksheet Functions | |||
Number Format Code won't work | Excel Discussion (Misc queries) | |||
code is not to work on sheet1 | New Users to Excel |