Minggu, 24 Juli 2011

RE: [ExcelVBA] VBA 'Like' using Cell Value

 

Are you sure you want to use "Like" If you just want to look up whatever is
in cell P17, then use "=" instead of "Like". Like would only be relevant if
P17 contains wildcards as well as text.

Best Regards
David Grugeon
Excel VBA Group Moderator

-----Original Message-----
From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of railroads@slingshot.co.nz
Sent: Sunday, 24 July 2011 4:52 PM
To: ExcelVBA@yahoogroups.com
Subject: [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

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

----------------------------------
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

----------------------------------Yahoo! Groups Links

__._,_.___
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