View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JCIrish JCIrish is offline
external usenet poster
 
Posts: 39
Default LOOKUP iterations in VBA 2007

In the sub below, LOOKUP returns a value (LookUpAnswer) that is copied to
cell G13 of a different sheet in the workbook. I need to repeat this
procedure 15 times, each time changing the first argument of LOOKUP (€śTotal A
BndfndIntermed€ť, in the example) and changing as well the cell into which the
return value is copied.

My problem: Nothing Ive tried has worked to clear the return value of a
given iteration of the code so as to return the correct value on subsequent
iterations. How can I do this?

A related question: I know that my approach is not the most economical or
elegant way of accomplishing what Im trying to do. Any suggestions for a
better approach that would run through the 15 iterations, each time changing
the LOOKUP argument and the cell range into which the return is copied?

Dim Lookupanswer
Dim LookupRange As Range
Set LookupRange = Worksheets("PortfolioByType").Range("C1:I20")
Lookupanswer = Application.WorksheetFunction _
.Lookup("TOTAL A BndFndIntermd", Worksheets("PortfolioBytype") _
.Range("C1:I120"))


Worksheets("AssetAllocation").Activate
Range("G13").Select
Selection.Value = Lookupanswer
Range("A1").Select