If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > variables and strings

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-14-04, 07:44
fabalicious fabalicious is offline
Registered User
 
Join Date: Apr 2004
Posts: 11
variables and strings

What I'm trying to do is to get a cell's value and use it in an expression. The problem is that the row number of that cell has been obtained by a match-search and is contained in the variable "myRow".

The following expression doesn't work

ActiveCell.FormulaR1C1 = "=indirect(myRow,2))"

because the variable "myRow" is contained in a string, therefore the string "myRow" is written instead of its value.

Anyone an idea how I can bypass this problem?

Thanks!

Fabalicious
Reply With Quote
  #2 (permalink)  
Old 04-14-04, 08:43
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi again

Try

ActiveCell.FormulaR1C1 = "=indirect(" & myRow & ",2))"

I am not familiar with indirect but I am not sure that is the correct for looking at the help for INDIRECT, but as before I am probably wrong.

Perhaps this instead

ActiveCell = "=indirect(" & cells(myRow,2).address & ")"

Let me know

MTB
Reply With Quote
  #3 (permalink)  
Old 04-14-04, 09:56
fabalicious fabalicious is offline
Registered User
 
Join Date: Apr 2004
Posts: 11
Hi Mike

Both didn't work unfortunately.
I'll let you know when i got a solution, thanks anyway

F
Reply With Quote
  #4 (permalink)  
Old 04-14-04, 10:06
fabalicious fabalicious is offline
Registered User
 
Join Date: Apr 2004
Posts: 11
ActiveCell.FormulaR1C1 = "=indirect(address(" & myRow + 1 & ",2))"

... does the job!

F
Reply With Quote
  #5 (permalink)  
Old 04-14-04, 10:53
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Thanks for letting me know

Address() is another worksheet function I don't recall using before, you live and learn.

Hence my pre-occupation with this, which also appeares to work

ActiveCell = "=indirect(" & Cells(myrow + 1, 2).Address & ")"


Thank again


MTB
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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