Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Loop Through worksheets Stephen[_9_] Excel Programming 5 April 20th 04 01:46 PM
Loop worksheets Steve[_35_] Excel Programming 3 November 25th 03 04:46 AM


All times are GMT +1. The time now is 04:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"