Excel VBA: Copy Values Only to Blank Destination Cells
Question details
Copy values from a vertical source range into blank cells in a horizontal destination range without changing populated cells.

- Product
- Microsoft Excel VBA
- Device & OS
- not provided
- Scenario
- A macro maps the 52 values in H9:H60 to the 52 destination cells in E7:BD7.
- Observed behavior
- The existing macro stops when it encounters the first populated destination cell instead of checking the remaining cells.
Confirm that H9:H60 and E7:BD7 are on the intended worksheet and that each source row should map to the corresponding destination column. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros only if you trust the file.
Loop through every destination cell and fill only empty cells
Use direct range references to preserve populated cells and continue checking the rest of the destination range.
The loop maps H9 to E7, H10 to F7, and so on through H60 to BD7. Each source position stays paired with its destination even when a populated cell is skipped.
In Excel, press Alt+F11, then choose Insert > Module.
Paste the following code into the module and replace Sheet1 with the worksheet name containing both ranges: Sub CopyValuesToBlankCells() Dim ws As Worksheet Dim i As Long Set ws = ThisWorkbook.Worksheets("Sheet1") For i = 1 To 52 If IsEmpty(ws.Cells(7, 4 + i).Value2) Then ws.Cells(7, 4 + i).Value2 = ws.Cells(8 + i, 8).Value2 End If Next i End Sub
Return to Excel, press Alt+F8, select CopyValuesToBlankCells, and click Run. Check E7:BD7 to confirm that existing entries remain unchanged and later blank cells receive their corresponding source values.

Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and compatibility with Excel formats, making it easy to move everyday spreadsheet work between applications. It does not fix Excel VBA, and macro compatibility can vary.

Frequently Asked Questions
Will the macro stop when it finds a populated destination cell?
No. The For loop checks all 52 destination positions. The If statement skips assignment for populated cells and then continues to the next position.
Does the macro shift source values when it skips a cell?
No. Each source row remains paired with its destination column. For example, if E7 is populated, H9 is skipped and H10 is still mapped to F7.
What if the source and destination are on different worksheets?
Create separate worksheet variables for the source and destination, then use the source variable for Cells(8 + i, 8) and the destination variable for Cells(7, 4 + i). Set each variable with ThisWorkbook.Worksheets("SheetName").
Will a formula returning an empty string be overwritten?
No. The IsEmpty test does not treat a formula cell as genuinely empty, even if the formula displays an empty string.
How do I save the macro for later use?
In Excel, choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). Saving as .xlsx removes VBA macros.




