ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sheets(count) code (https://www.excelbanter.com/excel-programming/283064-sheets-count-code.html)

Young-Hwan Choi

sheets(count) code
 
Hello.

I have several sheets, named A, B, C, D, ...., 1,2,3,.....and so on in a
workbook.

I want to do job WWW in each sheet named 1,2,3,...(not A,B,C,...)
when I tried with
For kkk = 1 to 15
sheets(kkk).select
WWW
next kkk
it changes from sheet A. I understand sheets(kkk) means kkk-th sheet in a
workbook.

How do I specify a sheet named variable kkk ?
Say, I want to select sheets("1") at first, then sheets("2"), and so on...

thanks.



Harald Staff

sheets(count) code
 
Hi

How about

Sub test()
Dim Ws As Worksheet
For Each Ws In ActiveWorkbook.Worksheets
If IsNumeric(Ws.Name) Then
Ws.Select
MsgBox Ws.Name
End If
Next
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Young-Hwan Choi" skrev i melding
...
Hello.

I have several sheets, named A, B, C, D, ...., 1,2,3,.....and so on in a
workbook.

I want to do job WWW in each sheet named 1,2,3,...(not A,B,C,...)
when I tried with
For kkk = 1 to 15
sheets(kkk).select
WWW
next kkk
it changes from sheet A. I understand sheets(kkk) means kkk-th sheet in a
workbook.

How do I specify a sheet named variable kkk ?
Say, I want to select sheets("1") at first, then sheets("2"), and so on...

thanks.





Cecilkumara Fernando

sheets(count) code
 
Choi,
try this
Sub addData()
For i = 1 To Worksheets.Count
Worksheets(i).Activate
If IsNumeric(ActiveSheet.Name) Then
Range("A1") = ActiveSheet.Name
End If
Next
End Sub

Cecil

"Young-Hwan Choi" wrote in message
...
Hello.

I have several sheets, named A, B, C, D, ...., 1,2,3,.....and so on in a
workbook.

I want to do job WWW in each sheet named 1,2,3,...(not A,B,C,...)
when I tried with
For kkk = 1 to 15
sheets(kkk).select
WWW
next kkk
it changes from sheet A. I understand sheets(kkk) means kkk-th sheet in a
workbook.

How do I specify a sheet named variable kkk ?
Say, I want to select sheets("1") at first, then sheets("2"), and so on...

thanks.





Paul Robinson

sheets(count) code
 
Hi
Try sheets(""&kkk).activate

The & character forces kkk to be text. There is probably some VBA
function that converts numbers to text too.

regards
Paul
"Young-Hwan Choi" wrote in message ...
Hello.

I have several sheets, named A, B, C, D, ...., 1,2,3,.....and so on in a
workbook.

I want to do job WWW in each sheet named 1,2,3,...(not A,B,C,...)
when I tried with
For kkk = 1 to 15
sheets(kkk).select
WWW
next kkk
it changes from sheet A. I understand sheets(kkk) means kkk-th sheet in a
workbook.

How do I specify a sheet named variable kkk ?
Say, I want to select sheets("1") at first, then sheets("2"), and so on...

thanks.


Young-Hwan Choi

sheets(count) code
 
Paul

This is exactly what I want, simple and works great.
Appreciate your help

regards,
choi




All times are GMT +1. The time now is 07:21 PM.

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