View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Need to you quotations ("") in a string.

Double up the quotes...

With Sheets("Summary")
.Range("D34").Formula = "=SUMPRODUCT(--(" & Depts &
"Dates<=$J$4),--(" & Depts & "Indicators=""X"")," & Depts & "Hours)*(1+$J$10)"

End With

--
HTH...

Jim Thomlinson


"RyanH" wrote:

I have a formula that requires quotations around the X in the formula but VBA
will not allow me to do it. Is there a way around this because I have to
have the quotations around the X in the formula bar for the formula to work.

Sub InsertFormula()

Const Depts As String = "Engineering"

With Sheets("Summary")
.Range("D34").Formula = "=SUMPRODUCT(--(" & Depts &
"Dates<=$J$4),--(" & Depts & "Indicators="X")," & Depts & "Hours)*(1+$J$10)"

End With
End Sub
--
Cheers,
Ryan