SilverTRader
New Member
- Joined
- Apr 30, 2013
- Messages
- 9
Sheet 1 is created with VBA code and populated with data starting at Row 6 from an Access recordset object.
Row J is Requested Date. It can be null or the latest date.
Row K is the number of Requested Dates - it can be Null (if the date is empty), 1 or many
In the case the number in K > 1 - We want the format of the Date to be changed. This way the report shows more than one date exist.
Example of the Objective
Date .......Number
1/1/2013 ..1
1/1/2013 ..3 ' Greater than 1 - formated Date fonts
....................' both blank
1/1/2013 ..1
My current way to do this is with:
The problem with the last code (that works) is when the end Excel user wants to do a "what if" and change a number from 1 to 2 -
the date won't reformat. The question code above would allow the end Excel user to see the changes update.
Row J is Requested Date. It can be null or the latest date.
Row K is the number of Requested Dates - it can be Null (if the date is empty), 1 or many
In the case the number in K > 1 - We want the format of the Date to be changed. This way the report shows more than one date exist.
Example of the Objective
Date .......Number
1/1/2013 ..1
1/1/2013 ..3 ' Greater than 1 - formated Date fonts
....................' both blank
1/1/2013 ..1
Code:
' Runs but doesn't provide the intended results
Sub Macro6()
With Sheets(1)
Application.Goto .Range("J6")
With .Range("J6:J" & .Range("A" & .Rows.Count).End(xlUp).Row)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=ActiveCell.Offset(-1, 0) > 2"
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorAccent3
.TintAndShade = -0.249946592608417
End With
.FormatConditions(1).StopIfTrue = True
End With
End With
End Sub
My current way to do this is with:
Code:
' introwpos is Row 6 - intMaxRecordCount is the number of records from MSAccess
1590 With ObjXL.ActiveWorkbook.ActiveSheet
1600 For i = intRowPos To intMaxRecordCount + intRowPos
1610 If .Cells(i, "B").value <> .Cells(i - 1, "B").value Then
1620 .Range(.Cells(i, "B"), .Cells(i, "B")).Font.FontStyle = "Bold"
'.Cells(i, 33).Value = .Cells(i, 3).Value
1630 Else
'Another format option
1640 End If
1650 Next i
The problem with the last code (that works) is when the end Excel user wants to do a "what if" and change a number from 1 to 2 -
the date won't reformat. The question code above would allow the end Excel user to see the changes update.