ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Upper, Lower & Proper case (https://www.excelbanter.com/excel-programming/366657-upper-lower-proper-case.html)

VBA Noob[_17_]

Upper, Lower & Proper case
 

Hi all,

I've got the below code which I want to reduce down to two lines. Wha
do I need to do Instead of using a upper and lower case "a" & "b"


Code
-------------------

Sub FillColours()
Dim c As Range

Cells.Select
Selection.Interior.ColorIndex = xlNone
For Each c In Range("C1:C" & Cells(Rows.Count, 3).End(xlUp).Row)

Select Case c
Case "*a*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 36
Case "A"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 36
Case "*b*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 35
Case "*B*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 35
End Select
Next c
End Sub

-------------------


Thanks in advance

VBA Noo

--
VBA Noo
-----------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...fo&userid=3383
View this thread: http://www.excelforum.com/showthread.php?threadid=55958


Ardus Petus

Upper, Lower & Proper case
 
Hi Noob,

Select case LCase(c)
Case "*a*"
blah
Case "*b*""
blah
end select

HTH
--
AP

"VBA Noob" a écrit
dans le message de news:
...

Hi all,

I've got the below code which I want to reduce down to two lines. What
do I need to do Instead of using a upper and lower case "a" & "b"


Code:
--------------------

Sub FillColours()
Dim c As Range

Cells.Select
Selection.Interior.ColorIndex = xlNone
For Each c In Range("C1:C" & Cells(Rows.Count, 3).End(xlUp).Row)

Select Case c
Case "*a*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 36
Case "A"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 36
Case "*b*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 35
Case "*B*"
Range(c.Offset(0, -2), c.Offset(0, 34)).Interior.ColorIndex = 35
End Select
Next c
End Sub

--------------------


Thanks in advance

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile:
http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=559586




VBA Noob[_18_]

Upper, Lower & Proper case
 

Thanks.

Works a treat.

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=559586



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com