I´m trying out CASE for the first time in VB. I´m starting out with a simple cell format but it gives me an error on case 2, please look at the code below. Can anybody give me a reason why and maybe some pointers?
Number = 4
Select Case Number
Case 1
Cells(1, 10).Select
With Selection.Interior
.Color = 255
Case 2
Cells(1, 11).Select
With Selection.Interior
.Color = 255
Case 3
Cells(1, 12).Select
With Selection.Interior
.Color = 255
Case 4
Cells(1, 13).Select f
With Selection.Interior
.Color = 255
Case 5
Cells(1, 14).Select
With Selection.Interior
.Color = 255
Case Else
Cells(2, 14).Select
With Selection.Interior
.Color = 255
End Select
Sub AAA()
Number = 4
Select Case Number
Case 1 To 5: Cells(1, Number + 9).Interior.Color = 255
Case Else: Cells(2, 14).Interior.Color = 255
End Select
End Sub
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.