Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Would like to format conditionally using VB. I know how to use "conditional
format" on a cell in the spreadsheet, but want to do this in the code. In particular, I have thousands of rows of "events". Content of first two cells in each are strings representing time. The function "get_diff" returns difference, in seconds. So cell A3 contains "='PERSONAL.xls'!Module1.get_diff(A1,A2)" Function get_diff(str0 As String, str1 As String, Optional dbg_flag As Boolean = False) As Double Dim xDiff As Double xDiff = convert_to_sec(str1, dbg_flag) - convert_to_sec(str0, dbg_flag) If dbg_flag Then MsgBox "Diff is " & Format(xDiff, "#######.######") End If get_diff = xDiff End Function How do I format the cell that gets the result based on value returned from get_diff? That is the A3 (or any other cell from which I called get_diff) gets formatted based on the result. I can't figure out how to select the cell in the code. I need something like: If xDiff 3.001 Then .....Font.Bold = True .....Font.ColorIndex = 3 Else .....Font.Bold = False .....Font.ColorIndex = 10 Endif |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Format based on forumula result | Excel Discussion (Misc queries) | |||
IF function based on True result with large formula. | Excel Programming | |||
Can Excel operate a function based on a true or false result? | Excel Worksheet Functions | |||
format cell based on results of vlookup function | Excel Worksheet Functions | |||
how do I insert a row based on a function result | Excel Worksheet Functions |