Syntax for else elsif advice for £ character

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,830
Office Version
  1. 2007
Platform
  1. Windows
I have this code in use below.
Im having an issue with £ charcter where it just turns to yellow as its incorrect syntax i assume.

Can you advise please


VBA Code:
Dim Cell As Range
For Each Cell In Range("L:L")
  If Cell = "TO DO" Then
     Cell.Interior.Color = vbRed
    
  ElseIf Cell = "DONE" Then
     Cell.Interior.Color = vbBlue
    
  ElseIf Cell = ("£") Then
     Cell.Interior.Color = vbGreen
    
  End If
  Next Cell

Application.ScreenUpdating = True
 
@dmt32
I have applied the code you advised thanks & i can say it works but i see one issue.

My table is currectly A5:L27 BUT i see column L have the White background applied still upto row 31,see screenshot

I change the lines as shown as was to dark & now im able to select a lighter color by using Interior.ColorIndex

VBA Code:
    For Each Cell In Cells(5, "L").Resize(Cells(Rows.Count, "L").End(xlUp).Row)
    
        If Cell.Text = "TO DO" Then
            Cell.Interior.ColorIndex = 4 ' GREEN
            
        ElseIf Cell.Text = "DONE" Then
            Cell.Interior.ColorIndex = 33 ' BLUE
            
        ElseIf Cell.Text Like "£*" Then
            Cell.Interior.ColorIndex = 3 ' RED
        Else
        Cell.Interior.ColorIndex = 2 ' WHITE
        End If
        
    Next Cell
 

Attachments

  • EaseUS_2024_05_18_15_47_06.jpg
    EaseUS_2024_05_18_15_47_06.jpg
    14.8 KB · Views: 7
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I added that line thinking you may want to restore the colour to white - just delete the line if not wanted

Dave
 
Upvote 0
Ah ok thanks.
Strange it does what it does even though it’s outside of the table.
Nice to use it so will change the colour & have it the same all under the table.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,728
Members
452,939
Latest member
WCrawford

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