Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
cw cw is offline
external usenet poster
 
Posts: 4
Default refering to a variable in a cell.formula

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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default refering to a variable in a cell.formula

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






  #3   Report Post  
Posted to microsoft.public.excel.programming
cw cw is offline
external usenet poster
 
Posts: 4
Default refering to a variable in a cell.formula

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








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default refering to a variable in a cell.formula

Sometime I have to use a temporary variable to get it to work. It is also
easier to debug problems doing it this way.

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

"cw" wrote:

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









  #5   Report Post  
Posted to microsoft.public.excel.programming
cw cw is offline
external usenet poster
 
Posts: 4
Default refering to a variable in a cell.formula

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












  #6   Report Post  
Posted to microsoft.public.excel.programming
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











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default refering to a variable in a cell.formula

that may be exactly what you want, but hard coding in the value of a cell in
your match formula is not the same a refering to that cell as in your
original post.


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

Will put in the cell reference in the formula instead of the current value
of the cell (continuing to work if the cell value changes.

--
Regards,
Tom Ogilvy


"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











  #8   Report Post  
Posted to microsoft.public.excel.programming
cw cw is offline
external usenet poster
 
Posts: 4
Default refering to a variable in a cell.formula

Thanks for that, although you are right I don't need it as the end result
will be made to a CSV file for a database import.

but thanks again, that will come in handy in the future I am sure

Craig



"Tom Ogilvy" wrote in message
...
that may be exactly what you want, but hard coding in the value of a cell
in
your match formula is not the same a refering to that cell as in your
original post.


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

Will put in the cell reference in the formula instead of the current value
of the cell (continuing to work if the cell value changes.

--
Regards,
Tom Ogilvy


"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













Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
refering to specific cell in the formula need a help[_2_] Excel Discussion (Misc queries) 6 July 25th 08 03:39 AM
Refering to an object with a variable Cory Excel Programming 2 September 28th 06 06:17 PM
autofill with one part of the formula refering to a constant cell old grey whiskers Excel Discussion (Misc queries) 3 August 19th 06 06:24 AM
refering to a range with a variable eyecalibrate[_2_] Excel Programming 2 March 1st 04 04:06 PM
Simple problem refering to variable in For ... Next loop ... Chris Excel Programming 1 July 15th 03 01:00 AM


All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"