Adding a variable to a formula with vba

a102072

New Member
Joined
Feb 1, 2021
Messages
2
Platform
  1. Windows
I know this is going to come down to some sort of silly formatting issue but...I keep getting a "compile syntax error" on line 13. Of course, I tried changing it many different ways but it still won't compile an run. BTW, this is in Excel 2003 which I guess I've forgotten since I've been using the latest and greatest at other client sites. Can someone assist, thanks?
.............
Dim cell As Integer
cell = 10

For Counter = 1 To 2
' ActiveCell.Offset(1, 0).Range("A1").Select
Selection.FormatConditions.Delete
' Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$T$9>$R$9"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=""=$T$"&cell&">$R$"&cell""
' Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$T$Call i()>$R$Call i()"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 50
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$T$i<$R$i"
With Selection.FormatConditions(2).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=$R$i"
ActiveCell.Offset(1, 0).Range("A1").Select
' Workbook.Add (cell:=10)
Next Counter
End Sub
...............
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

aRandomHelper

Active Member
Joined
Jan 14, 2021
Messages
304
Office Version
  1. 2016
Platform
  1. Windows
I assume you meant this line?
VBA Code:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$T$" & cell & ">$R$" & cell
 

Forum statistics

Threads
1,176,265
Messages
5,902,239
Members
434,953
Latest member
matthiasarnbert

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top