Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
thorsten
 
Posts: n/a
Default How can I use variables in formulas in VB?


Hello,
I would like to integrate variables in formulas in Visual Basic, but I
don't now how to do.

My current problem is that I have to use the VLOOKUP-command in a loop,
but I can't find the solution how to define the "table_array"-entry as a
range that is changing.

So, how can I define a range (where I include my varibles) and what
command do I need to use this range in my formula?
Please help me...


Thanks a lot,

Thorsten


--
thorsten
------------------------------------------------------------------------
thorsten's Profile: http://www.excelforum.com/member.php...o&userid=34496
View this thread: http://www.excelforum.com/showthread...hreadid=542619

  #2   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default How can I use variables in formulas in VB?


http://www.excelforum.com/showthread.php?t=542637 might help.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=542619

  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How can I use variables in formulas in VB?

Untested....

Option Explicit
Sub Testme()
Dim myRng as range
dim myCell as range
dim myTable as range
dim res as variant

with worksheets("Sheet99")
set myrng = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

with worksheets("sheet101010")
set myTable = .range("a:E")
end with

for each mycell in myrng.cells
res = application.vlookup(mycell.value,mytable,2,false)
if iserror(res) then
'like #n/a in excel
mycell.offset(0,3).value = "Missing"
else
mycell.offset(0,3).value = "Found: " & res
end if
next mycell
end sub

Sometimes it's easier to just plop the =vlookup()'s in the cells you want and
then convert them to values--not doing any of the =vlookup() in code.



thorsten wrote:

Hello,
I would like to integrate variables in formulas in Visual Basic, but I
don't now how to do.

My current problem is that I have to use the VLOOKUP-command in a loop,
but I can't find the solution how to define the "table_array"-entry as a
range that is changing.

So, how can I define a range (where I include my varibles) and what
command do I need to use this range in my formula?
Please help me...

Thanks a lot,

Thorsten

--
thorsten
------------------------------------------------------------------------
thorsten's Profile: http://www.excelforum.com/member.php...o&userid=34496
View this thread: http://www.excelforum.com/showthread...hreadid=542619


--

Dave Peterson
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
How to change column letters to correct ones in many formulas automatically? Dmitry Kopnichev Links and Linking in Excel 7 October 13th 05 09:52 PM
How to change column letters to correct ones in many formulas automatically? Dmitry Kopnichev Excel Worksheet Functions 7 October 13th 05 09:52 PM
how can i get formulas in excel to copy and paste? bman Excel Worksheet Functions 1 October 3rd 05 04:15 PM
How prevent formulas to get external references/path to current workbook? Gunnar Johansson Excel Worksheet Functions 1 August 15th 05 10:39 AM
calculating formulas for all workbooks in a folder Chad Excel Worksheet Functions 3 November 13th 04 05:22 PM


All times are GMT +1. The time now is 11:57 PM.

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

About Us

"It's about Microsoft Excel"