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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,626
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,626
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,626
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,626
Office Version
365
Platform
Windows
Glad to help & thanks for the feedback
 

Forum statistics

Threads
1,089,489
Messages
5,408,565
Members
403,215
Latest member
DblDocWhitaker

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top