I am having some problems trying to add conditional formatting to my excel sheet via access vba
I can add validation rules ok as below, but can't seem to convert the excel macro code created when setting up the cond/format rule.
any help is appreciated.
this works ok
With Current_Worksheet.Range("F" & Mid(last_cell, 4, 3) + 2).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Sheet1!$A$1:$A$2"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
With Current_Worksheet.Range("$K8:K" & Mid(last_cell, 4, 3)).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=sheet1!$A$4:$A$15"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
this is the macro from excel, can't seem to convert this in access vba code.
Sub Macro2()
' Macro2 Macro
Range("C8:F19").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=LEN(TRIM(C8))=0"
Selection.FormatConditions(Selection.FormatConditi ons.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
End Sub
i tried this but no go, it fails on first line of formatconditions. as this is not in the access lib?
Current_Worksheet.Range("C8:F19").Select
With Selection
.FormatConditions.Add Type:=xlExpression, Formula1:="=LEN(TRIM(C8))=0"
.FormatConditions(Selection.FormatConditions.Count ).SetFirstPriority
.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True