ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop thru worksheets(i) (https://www.excelbanter.com/excel-programming/409139-loop-thru-worksheets-i.html)

Jim at Eagle

Loop thru worksheets(i)
 
Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle

Don Guillett

Loop thru worksheets(i)
 
Sub clearsheets()
For i = 22 To 31 ' Sheets.Count
Sheets(i).Range("j14:k28").ClearContents
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim at Eagle" wrote in message
...
Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle



Gary''s Student

Loop thru worksheets(i)
 
Sub mersion()
Dim i As Integer
For i = 1 To 31
Worksheets(i).Activate
ActiveSheet.Range("J14:K28").ClearContents
Next
End Sub

--
Gary''s Student - gsnu200778


"Jim at Eagle" wrote:

Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle


DomThePom

Loop thru worksheets(i)
 
Works fine for me - are you sure you have 32 sheets in your workbook?

"Jim at Eagle" wrote:

Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle


Jim at Eagle

Loop thru worksheets(i)
 
Thanks for your help.
I get a runtime error 9 subscript out of range
there were two other suggestions to my request that when limited to sheets
22-32 i would get same error.
When allowing i to start at 1 it would happly work trashing a few extra
sheets.
Any suggestions?
excel 2003 xppro and there are more then 32 sheets.

--
Jim at Eagle


"Don Guillett" wrote:

Sub clearsheets()
For i = 22 To 31 ' Sheets.Count
Sheets(i).Range("j14:k28").ClearContents
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim at Eagle" wrote in message
...
Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle




Jim at Eagle

Loop thru worksheets(i)
 
I tried to use two nested DO While loops still would fail.
Then there was the following:

For i = 1 To 11
Worksheets("PReport " & i).Range("J14:K28").ClearContents
Next

I'm back in business, Thanks for your help.
I got where I was going but still would be nice to know why I couldn't go
the way I wanted to.
--
Jim at Eagle


"Jim at Eagle" wrote:

Thanks for your help.
I get a runtime error 9 subscript out of range
there were two other suggestions to my request that when limited to sheets
22-32 i would get same error.
When allowing i to start at 1 it would happly work trashing a few extra
sheets.
Any suggestions?
excel 2003 xppro and there are more then 32 sheets.

--
Jim at Eagle


"Don Guillett" wrote:

Sub clearsheets()
For i = 22 To 31 ' Sheets.Count
Sheets(i).Range("j14:k28").ClearContents
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim at Eagle" wrote in message
...
Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle




Don Guillett

Loop thru worksheets(i)
 
The only reason I can think of is that you had some chart sheets and I
should have suggested
worksheets.
instead of
sheets.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim at Eagle" wrote in message
...
I tried to use two nested DO While loops still would fail.
Then there was the following:

For i = 1 To 11
Worksheets("PReport " & i).Range("J14:K28").ClearContents
Next

I'm back in business, Thanks for your help.
I got where I was going but still would be nice to know why I couldn't go
the way I wanted to.
--
Jim at Eagle


"Jim at Eagle" wrote:

Thanks for your help.
I get a runtime error 9 subscript out of range
there were two other suggestions to my request that when limited to
sheets
22-32 i would get same error.
When allowing i to start at 1 it would happly work trashing a few extra
sheets.
Any suggestions?
excel 2003 xppro and there are more then 32 sheets.

--
Jim at Eagle


"Don Guillett" wrote:

Sub clearsheets()
For i = 22 To 31 ' Sheets.Count
Sheets(i).Range("j14:k28").ClearContents
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jim at Eagle" wrote in message
...
Dim i As Byte
i = 22
Do While i < 32
Worksheets(i).Range("J14:K28").ClearContents
i = i + 1
Loop

I have tried many ways but allways get one of several errors when the
worksheet line is run. Any help here will be greatly appreciated.
--
Jim at Eagle





All times are GMT +1. The time now is 05:29 AM.

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