Filling out blank spaces with previous value

edTech

New Member
Joined
Dec 8, 2019
Messages
33
Office Version
  1. 2019
Platform
  1. Windows
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:
A​
B​
C​
TimeStart RaceEnd Race
225586.586.5
263498.5
578988.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
 
You're welcome & thanks for the feedback
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,215,230
Messages
6,123,752
Members
449,118
Latest member
kingjet

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