willemeulen

12-07-2009, 05:13 AM

Still new in VBA and only learning it piece by piece:banghead: . I picked up old excel project of mine and just playing around to get some VBA working. Picked two items I want to achieve which I think are usefull in other sheets and give me the first baby steps how VBA works.

Firt one is GET FORMULA

Got the following VBA

Function GetFormula(Cell as Range) as String

GetFormula = Cell.Formula

End Function

works when typing into cell

=GetFormula(A1)

Returns the actual formula in writing

Like =A3*B3

But want to modify the VBA to get it working when I use a vlookup instead of dircet reference to cell and I want it to return the actual formula working (I have a Lookup table which contains formula's using the Row() as refferene in formula, so formula works on other sheet. Formula's can either be noted with or without equal sign in front. To be clear the formulas in the lookup tabel actually don't give any usefull answer but when transferred/coppied to destination cell (other sheet) the input value's are in fixed columns.

Any help in welcome:help .

Cheers

Firt one is GET FORMULA

Got the following VBA

Function GetFormula(Cell as Range) as String

GetFormula = Cell.Formula

End Function

works when typing into cell

=GetFormula(A1)

Returns the actual formula in writing

Like =A3*B3

But want to modify the VBA to get it working when I use a vlookup instead of dircet reference to cell and I want it to return the actual formula working (I have a Lookup table which contains formula's using the Row() as refferene in formula, so formula works on other sheet. Formula's can either be noted with or without equal sign in front. To be clear the formulas in the lookup tabel actually don't give any usefull answer but when transferred/coppied to destination cell (other sheet) the input value's are in fixed columns.

Any help in welcome:help .

Cheers