Sabtu, 23 Juli 2011

[ExcelVBA] VBA 'Like' using Cell Value

 

Hi

I want to replace this line of code that looks for "Chapter":

If LCase(Range("A" & i).Value) Like "chapter*" Then Range("b" & i).Font.size = 20

This works well.

But I need the value in a cell to be looked for. Say cdell P17. Cell changes value from time to time.

Have tried this code below but the code seems to miss the Like (Range("P17") part and changes all rows to size = 20.

If LCase(Range("A" & i).Value) Like (Range("p17").Value) Then Range("b" & i).Font.size = 20

Is there something not quite right?

Also I would like to add code re the font size to include Italics. Have tried this below but the & seems to be the problem. How do I include extra format codes.

.............Font.size = 20 & Font.Italic = True

Thanks

Charlie

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar