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
 

Some videos you may like

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).

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,430
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

fruela

New Member
Joined
Oct 23, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Yes, simple. Understood! Thanks Joe4
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,430
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,521
Messages
5,572,630
Members
412,475
Latest member
JaredNAU
Top