Paste formula in empty cells next to a variable range

davidmg1982

New Member
Joined
Oct 12, 2015
Messages
31
Im looking for a vba solution to paste a formula on the empty cells in Column D next to a variable range in column A, any help will be very appreciated.
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,764
Office Version
365
Platform
Windows
What is the variable range in A & what is the formula?
 

davidmg1982

New Member
Joined
Oct 12, 2015
Messages
31
What is the variable range in A & what is the formula?
Thanks Fluff, i might have used the wrong words, by variable range I meant total rows in column A will be changing every day.

The formula is:
"=IFERROR(HLOOKUP(RC[-3],DataForm!R3C3:R12C3,9,0),"""")"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,764
Office Version
365
Platform
Windows
Ok, do you want that formula in all col D down to the last row in col A, or just from the last used cell in D down to the last cell in col A, or something else?
 

davidmg1982

New Member
Joined
Oct 12, 2015
Messages
31
Ok, do you want that formula in all col D down to the last row in col A, or just from the last used cell in D down to the last cell in col A, or something else?
-The formula must be inserted in all blank cells in column D down to the last row in Column A, examples:

Example 1
Colums AColumn D
P12345Paste formula here
P12344Existent value
P15677Paste formula here
P12456Paste formula here

<tbody>
</tbody>

Example 2
Column AColumn D
P12985Existent value
P12644Existent value
P15932Paste formula here
P12546Existent value

<tbody>
</tbody>
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,764
Office Version
365
Platform
Windows
Ok, how about
Code:
Sub davidmg()
   With Range("D1:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=IFERROR(HLOOKUP(RC[-3],pcode!R3C3:R12C3,9,0),"""")"
   End With
End Sub
 

davidmg1982

New Member
Joined
Oct 12, 2015
Messages
31
Ok, how about
Code:
Sub davidmg()
   With Range("D1:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=IFERROR(HLOOKUP(RC[-3],pcode!R3C3:R12C3,9,0),"""")"
   End With
End Sub
Exactly what I need it, thank you for your time.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,764
Office Version
365
Platform
Windows
Glad to help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,089,763
Messages
5,410,286
Members
403,306
Latest member
ekastan

This Week's Hot Topics

Top