Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thank you, thank you!
i appreciate that and will learn from it. "Per Jessen" wrote in message ... Hi Scott Option Explicit Sub InsertFormula() Dim c As Range Dim i As Integer Set c = ActiveSheet.Range("C3") Do While c.Offset(0, -2).Value < "" i = c.Row c.Formula = "=IF(ISNA(VLOOKUP(A" & i & ",DataRange,1,FALSE)),"""",A" & i & ")" Set c = c.Offset(1, 0) Loop End Sub Regards Per "scott" skrev i en meddelelse ... thanks, but how do I make the formula's relative cell reference increment? wrote in message ... On 12¿ù13ÀÏ, ¿ÀÀü10½Ã38ºÐ, "scott" wrote: I'm trying to insert the formula shown in CODE 2 below into cells C3:C13. C3:C13 is a named range that always will be constantly growing, so my function InsertFormula() in CODE 1 should handle the range expanding dilema. My question is syntax with the formula. CODE 2 shows the formula needed in C3. However, when my function loops to the C4 cell, the formula being inserted needs to change from using A3 cell to the A4 cell, and so on until the function fills my range will the formula. Can someone help me modify my InsertFormula() function to insert the formula in each cell while incrementing the relative cell reference? CODE 1: Sub InsertFormula() Dim c As Range Set c = ActiveSheet.Range("C3") Do While c.Offset(0, -2).Value < "" c.Value = xxxxxx ' Should be my formula Set c = c.Offset(1, 0) Loop End Sub CODE 2: =IF(ISNA(VLOOKUP(A3,DataRange,1,FALSE)),"",A3) not c.Value , try c.Formula="=blahblah~" HTH sjoo |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Editing conditional formatting formula, arrow keys insert range. | Excel Discussion (Misc queries) | |||
Macro to insert a formula based on a range | Excel Discussion (Misc queries) | |||
Insert SUM Formula using VBA (Range Varies) | Excel Programming | |||
Macro to insert formula result into range with zero values in cell | Excel Programming | |||
How to insert formula to a range of cells from VBA? | Excel Programming |