View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Don Wiss Don Wiss is offline
external usenet poster
 
Posts: 300
Default Translating spreadsheet formula to VBA

On Sun, 5 Jun 2005 17:41:15 +0100, bharat <bharat.1q5xpb@ wrote:

I used a formula
(=OFFSET(AB3,MATCH(E5,$AB$4:$AB$71,0),MATCH(C5,$A C$3:$CR$3,0))) in Exel
sheet, it works fine but I tried to use the same in VBA in excel, but it
does not work. Any help will be highly appreciated.


This is untested, as I don't know your ranges, but it would go something
like this:

=Range("AC4:CR71").Cells(WorksheetFunction.Match(R ange("E5").Value,Range("AB4:AB71"),0),WorksheetFun ction.Match(Range("C5").Value,Range("AC3:CR3"),0)) .Value

The .Value inside the Match arguments may not be needed.

And better to give the ranges on the worksheet names, so you can
insert/delete rows/columns and move the cells around without crippling your
VBA code.

Don <www.donwiss.com (e-mail link at home page bottom).