Fill blank cells in column AH with value from column U (same row)

fruela

New Member
Joined
Oct 23, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I have this code that, for column X, fills all blanks with the value above. Range is same as W.

For column AH, I need to fill all blanks with the value from U, which is 13 columns to the left. (Example: AH4 = U4 ; AH20 = U20). Same range. Can you help me?

Cheers

VBA Code:
Sub copyToBlanks1()
    With Range("X2:X" & Range("W" & Rows.Count).End(xlUp).Row)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
    End With
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Does this do what you want:
VBA Code:
    With Range("AH2:AH" & Range("W" & Rows.Count).End(xlUp).Row)
        .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=RC[-13]"
        .Value = .Value
    End With
 
Upvote 0
Solution
You are welcome!

The trick is the "RC" part, which stands for row/column. The number in parenthesis after the R/C reference is the "offset" from that row column that the formula is being placed in.
So R[-1] means one row before the row that the formula is being placed in.
And C[-13] means 13 columns before the column that the formula is being placed in.
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,374
Members
448,888
Latest member
Arle8907

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