View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default refering to a variable in a cell.formula

Instead of chr(34) you can use "" (two double quotes together). You end up
with three double quotes together. I never get this right the 1st time.
that is why I usually use the temporary variable.

ActiveSheet.Cells(i, 12).Formula = "=MATCH("""
ActiveSheet.Cells(i, 6) & """,'Vaillant Brand list'!B$1:B$1861, 0)"


"cw" wrote:

Had to change it slightly

ActiveSheet.Cells(i, 12).Formula = "=MATCH(" & Chr(34) &
ActiveSheet.Cells(i, 6) & Chr(34) & ",'Vaillant Brand list'!B$1:B$1861, 0)"

but it works well

thanks for that
Craig




"cw" wrote in message
...
Nice

Giving it a go now

thanks
"Joel" wrote in message
...
ActiveSheet.Cells(i ,9).Formula = "=MATCH(" & _
ActiveSheet.Cells(1 ,"B") & ",'Brand list'!B$1:B$1861, 0)"

"cw" wrote:

Hi All

I just have a quick question, is it possible to refer to a variable in
the
formula below

where B1 is after MATCH, I want that to match the variable 'i' in the
Cells.(i,9)

ActiveSheet.Cells(i ,9).Formula = "=MATCH(B1,'Brand list'!B$1:B$1861,
0)"

Thanks
Craig