View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Create formula in VBA

What does it do now?

Try commenting the ".value = .value" line and look at the formula.

And a followup question...

You're using column O to determine the last cell to populate in column O.

Did you actually want that?

If you wanted to use column A:

Set frng = Range("O9:O" & Cells(Rows.Count, "a").End(xlUp).Row)





Heine wrote:

Hello

Sub makeformulae()
Dim frng As Range
Const sFormula As String = _
"=if(a9="""","""",if(isna(vlookup(a9,råb1,3,false) )," & _
""""",(vlookup(a9,råb1,3,false))))"
Sheets("Bogholderi").Select
Set frng = Range("O9:O" & Cells(Rows.Count, "O").End(xlUp).Row)
With frng
.Formula = sFormula
.Value = .Value
End With
End Sub

Does anybody know how I make this formula dynamic to go with the range
- so that the a9-lookup is returned in o9 and the a10-lookup is
returned in o10 etc. Any thoughts?

Thanks in advance.

/Heine


--

Dave Peterson