Jumat, 20 Januari 2017

RE: [ExcelVBA] Conditional Formatting using formula (operator Between)

 

Thanks for the tip Mann Sulaeman but I've finally worked it out.

Here is the code that solved my problem:

lLow = 0.001
lHigh = 2

lastrow = Worksheets("Sheet1").Range("J2").End(xlDown).Row
Set rng = Range("J3:J" & lastrow)
rng.FormatConditions.Delete

With rng.FormatConditions.Add(Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=" & lLow, Formula2:="=" & lHigh)
.NumberFormat = "0.00"
End With

The only question I have that is unresolved is this: I tried to declare my variables lLow and lHigh As Integer but when I did that it would include values equal to zero in the formatting, I had to delete my Dim declarations and it worked wonderfully. Why? What variable type is this routine using for those variables? I could not name the Dim As Decimal - I received a error message.

__._,_.___

Posted by: mgarza@fellowes.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

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