Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default If then else, or select case is giving me a problem

I have a Macro that dependent on a value in a cell of the worksheet,
SHOULD perform, but it isn't.
Based upon the value of cell H2, I need the macro to treat the data
manipulation in my code differently. The cutoff is 1. If the cell
value is one I need to treat the data one way, and any integer greater
than 1 needs to be treated differently.

If the value is greater than one, I have a For Each loop running which
serves as a counter for a dynamic array of integers. Whenever I run
the macro, and I get to the case of values Greater than 1, the initial
counter works (Values of 1 for the counter, not the cell the case is
evaluated). However, it never executes the second, third...nth
iteration of the values in the array. It just ends

I do know that the code for the actual manipulation works, as I have
run each of them in independent modules, and it performs as expected.
I have tried both "If Then Else" and "Select Case" and both loops give
me the same problem. Below is the code, with the actual manipulation
removed as I know it works. I have put a breakpoint in the code, and
stepped through it with the Locals Window open, and the counter never
advances past 1 for my second case, although it should.

Select Case Sheets("Sheet1").Range("H2").Value
Case Is = 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Is 1

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default If then else, or select case is giving me a problem

Case doesn't havve "IS" or "". try this

Select Case Sheets("Sheet1").Range("H2").Value
Case 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Else

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select



" wrote:

I have a Macro that dependent on a value in a cell of the worksheet,
SHOULD perform, but it isn't.
Based upon the value of cell H2, I need the macro to treat the data
manipulation in my code differently. The cutoff is 1. If the cell
value is one I need to treat the data one way, and any integer greater
than 1 needs to be treated differently.

If the value is greater than one, I have a For Each loop running which
serves as a counter for a dynamic array of integers. Whenever I run
the macro, and I get to the case of values Greater than 1, the initial
counter works (Values of 1 for the counter, not the cell the case is
evaluated). However, it never executes the second, third...nth
iteration of the values in the array. It just ends

I do know that the code for the actual manipulation works, as I have
run each of them in independent modules, and it performs as expected.
I have tried both "If Then Else" and "Select Case" and both loops give
me the same problem. Below is the code, with the actual manipulation
removed as I know it works. I have put a breakpoint in the code, and
stepped through it with the Locals Window open, and the counter never
advances past 1 for my second case, although it should.

Select Case Sheets("Sheet1").Range("H2").Value
Case Is = 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Is 1

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default If then else, or select case is giving me a problem

Of course it does

Dim var As Variant

var = 23

Select Case var

Case Is 7: MsgBox "10"
End Select


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Joel" wrote in message
...
Case doesn't havve "IS" or "". try this

Select Case Sheets("Sheet1").Range("H2").Value
Case 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Else

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select



" wrote:

I have a Macro that dependent on a value in a cell of the worksheet,
SHOULD perform, but it isn't.
Based upon the value of cell H2, I need the macro to treat the data
manipulation in my code differently. The cutoff is 1. If the cell
value is one I need to treat the data one way, and any integer greater
than 1 needs to be treated differently.

If the value is greater than one, I have a For Each loop running which
serves as a counter for a dynamic array of integers. Whenever I run
the macro, and I get to the case of values Greater than 1, the initial
counter works (Values of 1 for the counter, not the cell the case is
evaluated). However, it never executes the second, third...nth
iteration of the values in the array. It just ends

I do know that the code for the actual manipulation works, as I have
run each of them in independent modules, and it performs as expected.
I have tried both "If Then Else" and "Select Case" and both loops give
me the same problem. Below is the code, with the actual manipulation
removed as I know it works. I have put a breakpoint in the code, and
stepped through it with the Locals Window open, and the counter never
advances past 1 for my second case, although it should.

Select Case Sheets("Sheet1").Range("H2").Value
Case Is = 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Is 1

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default If then else, or select case is giving me a problem

Hi

What is the value of "carrier_array_upper"?


skrev i en meddelelse
...
I have a Macro that dependent on a value in a cell of the worksheet,
SHOULD perform, but it isn't.
Based upon the value of cell H2, I need the macro to treat the data
manipulation in my code differently. The cutoff is 1. If the cell
value is one I need to treat the data one way, and any integer greater
than 1 needs to be treated differently.

If the value is greater than one, I have a For Each loop running which
serves as a counter for a dynamic array of integers. Whenever I run
the macro, and I get to the case of values Greater than 1, the initial
counter works (Values of 1 for the counter, not the cell the case is
evaluated). However, it never executes the second, third...nth
iteration of the values in the array. It just ends

I do know that the code for the actual manipulation works, as I have
run each of them in independent modules, and it performs as expected.
I have tried both "If Then Else" and "Select Case" and both loops give
me the same problem. Below is the code, with the actual manipulation
removed as I know it works. I have put a breakpoint in the code, and
stepped through it with the Locals Window open, and the counter never
advances past 1 for my second case, although it should.

Select Case Sheets("Sheet1").Range("H2").Value
Case Is = 1

Sheets.Add.Name = "F" & single_carrier
......More Code Here

Case Is 1

For Each carrier In Sheets("Sheet1").Range("D2:D" &
carrier_array_upper)
'THIS IS WHERE THE COUNTER INITS AND SHOULD ITERATE
Sheets.Add.Name = "F" & carrier
Next carrier
End Select




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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select case and Last Cell Problem JamesBurrows Excel Programming 3 June 5th 06 05:51 PM
Problem with Select Case construct? Chris Bromley[_2_] Excel Programming 1 April 12th 05 08:27 PM
Select Case on a range - problem cdb Excel Programming 4 February 11th 05 01:37 PM
Problem With Select Case Steve[_27_] Excel Programming 18 August 6th 03 09:28 PM


All times are GMT +1. The time now is 06:26 PM.

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"