vba case without select case Compile Error

simora

Board Regular
Joined
May 7, 2005
Messages
199
I'm having problems implementing a Select Case statement. Keep getting case without select case at Case condition2.

Need help.

Thanks

Code:
Select Case Condition
    
          Case condition1
        
                    If Cells(rsRow, rsCol).Value = "" Then
                        Cells(rsRow, rsCol) = TextBox2.Value

	Case condition2
                 
                    If Cells(rsRow, rsCol).Value > 0 And iVal = 1 Then
                        Cells(rsRow, rsCol).Select
                        ActiveCell.Offset(1).EntireRow.Insert
                        ActiveCell.Offset(1, 0).Value = TextBox2.Value
	
	Case condition3

                  
                    If Cells(rsRow, rsCol).Value > 0 And iVal > 1 Then
			ActiveCell.Offset(1, 0).Value = TextBox3.Value
	Case Else

                            MsgBox "Case Else : The Code DID NOT Execute "
				ActiveCell.Offset(1, 0).Value = TextBox4.Value


    End Select
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
In the condition2 part try changing this:
ActiveCell.Offset(1).EntireRow.Insert

to this:
ActiveCell.Offset(1,0).EntireRow.Insert
 
Upvote 0
Your IFs need END IFs:

Code:
SELECT CASE ...

    Case ....
        IF ... Then
        End If

    Case ....
        IF ... Then
        End If

End SELECT
 
Upvote 0
Thanks Guys:

Both suggestions helped are are appreciated.
I've gotten it to work with some other little mods.

Thanks
 
Upvote 0

Forum statistics

Threads
1,216,058
Messages
6,128,538
Members
449,456
Latest member
SammMcCandless

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top