I have data in an excel sheet that has blank spaces in column B and C. I want to fill them with its previous values. I have the VbScript code below semi working as I think my issue is the FormulaR1C1, but I cannot get it to work. Any suggestions?
Sample Data:
Code:
With objReadWS
lastRow = .Range("B" & .Rows.Count).End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(2, 2), .Cells(lastRow, lastCol))
rng.Select
rng.SpecialCells(xlCellTypeBlanks).Select
rng.FormulaR1C1 = "=R[-1]C[2]"
rng.Select
rng.Copy
rng.PasteSpecial -4163, -4142, True, False
End With
Sample Data:
A | B | C |
Time | Start Race | End Race |
2255 | 86.5 | 86.5 |
2634 | 98.5 | |
5789 | 88.9 |
Code:
With objReadWS
lastRow = .Range("B" & .Rows.Count).End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(2, 2), .Cells(lastRow, lastCol))
rng.Select
rng.SpecialCells(xlCellTypeBlanks).Select
rng.FormulaR1C1 = "=R[-1]C[2]"
rng.Select
rng.Copy
rng.PasteSpecial -4163, -4142, True, False
End With