VBA Help!

steveo0707

Board Regular
Joined
Mar 4, 2013
Messages
85
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
The following is the code I have written for my worksheet. I am getting the program to do everything except for the last Case Parameters. It's not putting the © in the F column nor shading the cell green. I have also already tried making it an If statement and that did not work either.

VBA Code:
Sub Scanning()
    Dim YELLOW As Variant
    Dim OFF_GREEN As Variant
    Dim GREEN As Variant
    Dim Row As Long
    ' DEFINE THE COLORS
    YELLOW = RGB(255, 255, 91)
    OFF_GREEN = RGB(196, 215, 155)
    GREEN = RGB(54, 248, 54)
    ' CYCLE THROUGH ROWS
    Row = 1 
          
    Do Until Range("E" & Row).Value = VBA.Constants.vbNullString
        ' CHECKING COLUMN E
        Select Case Range("E" & Row).Value
            Case "Working On"
                Range("A" & Row).Interior.Color = YELLOW
            Case "In Box"
                Range("A" & Row & ":B" & Row).Interior.Color = YELLOW
            Case "Crate Built"
                Range("F" & Row).Value = "©"
                Range("F" & Row).Interior.Color = GREEN
                
         End Select
        
               ' IF YOU ARE LOOKING FOR JUST A LETTER D IN COLUMN F
        If Range("F" & Row).Value = "D" Then Range("C" & Row).Interior.Color = OFF_GREEN
               
        Row = Row + 1
    Loop
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Do you have any cells in col E with "Crate Built", bearing in mind that VBA is case sensitive?
Also check for any leading/trailing spaces.
 
Upvote 0
Yes, I have several cells with "Crate Built" and there are no extra spaces.
 
Upvote 0
What happens if you step through the code using F8. When you get to a row with Crate Built, does it move to this line
VBA Code:
Range("F" & Row).Value = "©"
 
Upvote 0
When I use F8, it runs through the code and only highlights the case lines but not any of the Range lines.
 
Upvote 0
In that case the values in col E are no exactly the same as the case statements. Bearing in mind crate built, Crate built, crate Built etc are not the same as Crate Built.
 
Upvote 0
I have attached a Screen shot of the work book
 

Attachments

  • Annotation 2020-04-09 084553.png
    Annotation 2020-04-09 084553.png
    100.8 KB · Views: 9
Upvote 0
Ok, in a blank cell put
=E4="Crate Built"
What does it return?
 
Upvote 0
Sounds like your "space' characters are not standard ones. What happens if you change your Select Case statement to this?

VBA Code:
Select Case Replace(Range("E" & Row).Value, Chr(160), " ")
 
Upvote 0
Also try
=CODE(MID(E4,6,1))
What does this return?
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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