Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have 4 worksheets named System 1,......System 4. The following code example has to be repeated 4 times to cover all sheets. If Worksheets("System 1").Cells(RC, 11).Value = "" Then blah blah blah If Worksheets("System 2").Cells(RC, 11).Value = "" Then blah blah blah and so on I would like to create a variable name called SheetNum and replace the actual number 1,2,3 and 4 with this variable. I will but this in a loop incrementing SheetNum each pass and the single line of code will cover my 4 sheets. This is what i have tried but will not compile. If Worksheets("System " + SheetNum + ")".Cells(RC, 11).Value = "" Then blah blah blah Thanks in advance for any help you can give me, Cheers! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"System " + SheetNum is a string plus an integer, you'll get a type mismatch.
Try "System " & SheetNum Sam "GC" wrote: Hi, I have 4 worksheets named System 1,......System 4. The following code example has to be repeated 4 times to cover all sheets. If Worksheets("System 1").Cells(RC, 11).Value = "" Then blah blah blah If Worksheets("System 2").Cells(RC, 11).Value = "" Then blah blah blah and so on I would like to create a variable name called SheetNum and replace the actual number 1,2,3 and 4 with this variable. I will but this in a loop incrementing SheetNum each pass and the single line of code will cover my 4 sheets. This is what i have tried but will not compile. If Worksheets("System " + SheetNum + ")".Cells(RC, 11).Value = "" Then blah blah blah Thanks in advance for any help you can give me, Cheers! . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perfect! Thanks a bunch Sam.
Gerry "Sam Wilson" wrote in message ... "System " + SheetNum is a string plus an integer, you'll get a type mismatch. Try "System " & SheetNum Sam "GC" wrote: Hi, I have 4 worksheets named System 1,......System 4. The following code example has to be repeated 4 times to cover all sheets. If Worksheets("System 1").Cells(RC, 11).Value = "" Then blah blah blah If Worksheets("System 2").Cells(RC, 11).Value = "" Then blah blah blah and so on I would like to create a variable name called SheetNum and replace the actual number 1,2,3 and 4 with this variable. I will but this in a loop incrementing SheetNum each pass and the single line of code will cover my 4 sheets. This is what i have tried but will not compile. If Worksheets("System " + SheetNum + ")".Cells(RC, 11).Value = "" Then blah blah blah Thanks in advance for any help you can give me, Cheers! . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
No Subject | Charts and Charting in Excel | |||
No Subject | Excel Discussion (Misc queries) | |||
No Subject | Excel Discussion (Misc queries) | |||
Not sure what to name this subject | Excel Programming | |||
No Subject | Excel Programming |