ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not sure what the subject is (https://www.excelbanter.com/excel-programming/436513-not-sure-what-subject.html)

GC

Not sure what the subject is
 
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!



Sam Wilson

Not sure what the subject is
 
"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!


.


GC

Not sure what the subject is
 
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!


.





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

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