Paste formula in empty cells next to a variable range

davidmg1982

Board Regular
Joined
Oct 12, 2015
Messages
64
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.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What is the variable range in A & what is the formula?
 
Upvote 0
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),"""")"
 
Upvote 0
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?
 
Upvote 0
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
[TABLE="width: 500"]
<tbody>[TR]
[TD]Colums A[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]P12345[/TD]
[TD]Paste formula here[/TD]
[/TR]
[TR]
[TD]P12344[/TD]
[TD]Existent value[/TD]
[/TR]
[TR]
[TD]P15677[/TD]
[TD]Paste formula here[/TD]
[/TR]
[TR]
[TD]P12456[/TD]
[TD]Paste formula here[/TD]
[/TR]
</tbody>[/TABLE]

Example 2
[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]P12985[/TD]
[TD]Existent value[/TD]
[/TR]
[TR]
[TD]P12644[/TD]
[TD]Existent value[/TD]
[/TR]
[TR]
[TD]P15932[/TD]
[TD]Paste formula here[/TD]
[/TR]
[TR]
[TD]P12546[/TD]
[TD]Existent value[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,945
Messages
6,175,556
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top