Excel VBA

Mar 14, 2023
Reaction score
Hi guys, I'm new on this forum and in VBA as well.

I need to dinamicaly fill a column with a formula and based on formula result (T or F) to apply Conditional Formating to cell in another column.
I've tried this:

Dim wsData As Worksheet
Set wsData = Worksheets("Sheet1")
With wsData
For i = 2 To Nr_ult - 1 ' Nr_Ult is Last row
Set Rng = .Range("C" & i)
.Range("AZ" & i) = "=IsValidMyFunctionl(.Range(""C"" & i))" ' OBJECT DEFINED ERROR
.Cells(i, 3).FormatConditions.Add Type:=xlExpression, Formula1:="=AZ" & i & "=TRUE"
.Cells(i, 3).FormatConditions(1).Interior.Color = RGB(200, 0, 0)
Next i
End With

I've tried also using Rng as function argument, but the formula is writen in cell exactly =IsValidMyFunctionl(Rng) Rng not being substituted with the value I expected to have, like =IsValidMyFunctionl(C2)......=IsValidMyFunctionl(C111)
I would appreciate any suggestions. Thanks.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question