Forum Discussion
Do not paste into cells that already contain data
Hi - I came across this whilst looking for a solution. I don't see how you can perform step 3 in your solution after selecting 'Values' in step 2. The dialog box is open and you have to paste. At what stage do you write the formula you provided?
In retrospect, I'm also a bit confused by the description of your project. Could you please explain it in more detail?
Step by step, what you're planning.
A file or photos might be helpful.
Thank you for your patience and understanding.
- BudgieJaneApr 24, 2025Copper Contributor
Some rows in my worksheet are partially filled with data. What I would like to do is complete one of those partially-filled rows of data by copying another row into the clipboard but only paste the copied values into the cells that do not contain any existing data, or which contain nulls.
It is similar to this pseudo-code
for cell in current row if value(cell) == null then value(cell) = clipboard(cell) endif endfor
- NikolinoDEApr 24, 2025Gold Contributor
You want to paste a row of values into a partially-filled row, but only fill in the empty cells — without overwriting anything that's already there.
This behavior is not something Excel does natively with normal copy/paste.
Use a VBA Macro for me the best way to do.
…since what you want isn't directly possible with just copy-paste functionality in Excel.
Here’s a simple macro that does exactly what your pseudocode describes:
Sub PasteOnlyIntoBlanks() Dim sourceRow As Range Dim targetRow As Range Dim c As Range Dim i As Integer ' Set the source and target rows Set sourceRow = Application.InputBox("Select source row", Type:=8) Set targetRow = Application.InputBox("Select target row", Type:=8) ' Loop through each cell in the row For i = 1 To sourceRow.Columns.Count If IsEmpty(targetRow.Cells(1, i)) Then targetRow.Cells(1, i).Value = sourceRow.Cells(1, i).Value End If Next i End Sub
How to use:
Press Alt + F11 to open the VBA editor.
Insert a new module.
Paste the code above.
Run the macro PasteOnlyIntoBlanks.
When prompted, select the source row (the one you copied).
Then select the target row (the partially-filled one).
Done! It fills only the blank cells with data from the source row.
If you an advance Excel User you can use Power Query.
Power Query can be used to merge rows and fill missing data programmatically — but it's a bit more advanced.