Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default For each next choking.

Greetings,

Here is my problem I have code similar to the following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a chart.
I've moved the chart and the choke time changes, so I know
that is an issue with the chart. But I need to know what
I can do to correct this. Any help in pointing me in the
right direction would be greatly appreciated. And anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For each next choking.

use thisworkbook.worksheets

in the for loop

Keith
www.kjtfs.co

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default For each next choking.

Hi
one way:
Dim theSheet as WorkSheet

For each theSheet in thisWorkBook.worksheets
Do some code...
next theSheet

--
Regards
Frank Kabel
Frankfurt, Germany

Jim Chandler wrote:
Greetings,

Here is my problem I have code similar to the following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a chart.
I've moved the chart and the choke time changes, so I know
that is an issue with the chart. But I need to know what
I can do to correct this. Any help in pointing me in the
right direction would be greatly appreciated. And anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default For each next choking.

Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in message ...
Greetings,

Here is my problem I have code similar to the following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a chart.
I've moved the chart and the choke time changes, so I know
that is an issue with the chart. But I need to know what
I can do to correct this. Any help in pointing me in the
right direction would be greatly appreciated. And anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default For each next choking.


-----Original Message-----
Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...
Greetings,

Here is my problem I have code similar to the following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second

iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a chart.
I've moved the chart and the choke time changes, so I

know
that is an issue with the chart. But I need to know

what
I can do to correct this. Any help in pointing me in

the
right direction would be greatly appreciated. And

anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim



.


Okay - My mistake, I transposed (right word?) the code
wrong it is actually "thisworkbook.worksheets"

Jim


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default For each next choking.

Hi Jim

Show your other code Jim that is in this sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in message ...

-----Original Message-----
Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...
Greetings,

Here is my problem I have code similar to the following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second

iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a chart.
I've moved the chart and the choke time changes, so I

know
that is an issue with the chart. But I need to know

what
I can do to correct this. Any help in pointing me in

the
right direction would be greatly appreciated. And

anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim



.


Okay - My mistake, I transposed (right word?) the code
wrong it is actually "thisworkbook.worksheets"

Jim



  #7   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default For each next choking.

Here is the code in it's entirety. I just copied and
pasted it so I hope you can read it.

Public Sub ComputeRollups()
Dim theSheet As Worksheet
Dim sum As Integer, numSummed As Integer
Dim theRow As Integer, theCol As Integer
Dim temp As String
For Each theSheet In ThisWorkbook.Sheets
If (theSheet.Name < "survey tracking" And
theSheet.Name < "Chart1" And theSheet.Name < "CIO sector
response" And theSheet.Name < "Yellow & Red Metrics") Then
For theRow = 5 To 36
sum = 0
If theRow = 10 Or theRow = 16 Or theRow =
21 Or theRow = 27 Or theRow = 32 Then
'skip row
Else
theCol = 4
sum = 0
Count = 0
Do While UCase$(theSheet.Cells(2,
theCol - 1).Value) < "ROLL-UP VALUE"
If UCase$(theSheet.Cells(1,
theCol - 1).Value) < "HQ Average" Then
temp = theSheet.Cells(2,
theCol - 1).Value
If theSheet.Cells(theRow,
theCol).Value 0 Then
sum = sum + theSheet.Cells
(theRow, theCol).Value
Count = Count + 1
End If
End If
theCol = theCol + 2
Loop
theSheet.Cells(theRow, theCol -
1).Value = CDbl(sum) / Count
End If
Next theRow
End If
Next theSheet
End Sub
-----Original Message-----
Hi Jim

Show your other code Jim that is in this sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...

-----Original Message-----
Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...
Greetings,

Here is my problem I have code similar to the

following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second

iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a

chart.
I've moved the chart and the choke time changes, so I

know
that is an issue with the chart. But I need to know

what
I can do to correct this. Any help in pointing me in

the
right direction would be greatly appreciated. And

anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim


.


Okay - My mistake, I transposed (right word?) the code
wrong it is actually "thisworkbook.worksheets"

Jim



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default For each next choking.

Well - I figured out the difference of what I had and what
you posted. It's Worksheets, not Sheets. Thanks for
putting up with my synaptic overload.

Jim
-----Original Message-----
Hi Jim

Show your other code Jim that is in this sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...

-----Original Message-----
Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...
Greetings,

Here is my problem I have code similar to the

following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second

iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a

chart.
I've moved the chart and the choke time changes, so I

know
that is an issue with the chart. But I need to know

what
I can do to correct this. Any help in pointing me in

the
right direction would be greatly appreciated. And

anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim


.


Okay - My mistake, I transposed (right word?) the code
wrong it is actually "thisworkbook.worksheets"

Jim



.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default For each next choking.

I see it Jim


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in message ...
Well - I figured out the difference of what I had and what
you posted. It's Worksheets, not Sheets. Thanks for
putting up with my synaptic overload.

Jim
-----Original Message-----
Hi Jim

Show your other code Jim that is in this sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in

message ...

-----Original Message-----
Try this

Dim theSheet As Worksheet
For Each theSheet In ThisWorkbook.Worksheets
'Do some code...
Next theSheet


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jim Chandler" wrote in
message ...
Greetings,

Here is my problem I have code similar to the

following

Dim theSheet as WorkSheet

For each theSheet in thisWorkBook
Do some code...
next theSheet

It runs the first iteration fine, but the second
iteration
gives me a runtime error "type mismatch".

What I have discovered, is the second sheet is a

chart.
I've moved the chart and the choke time changes, so I
know
that is an issue with the chart. But I need to know
what
I can do to correct this. Any help in pointing me in
the
right direction would be greatly appreciated. And
anyone
who just plain gives me the right answer I'll name my
first born after ;-).

Thanks,
Jim


.


Okay - My mistake, I transposed (right word?) the code
wrong it is actually "thisworkbook.worksheets"

Jim



.



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



All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"