VBA: Copy Paste Names into blank cells without copying over any information

I am looking to build a VBA macro that will take columns A and B in the attached sample and copy and paste each name/ username into the blank areas.
Ryan SimmonsBusiness Analyst IIIAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShumsExcel & VBA ExpertCommented:
Hi Ryan,

Try below:
Sub FillDown()
Dim LR As Long
LR = Cells(Rows.Count, "C").End(xlUp).Row
Application.ScreenUpdating = False
With Sheets("Sheet1").Range("A2:B" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
Application.ScreenUpdating = True
End Sub

Open in new window

Check in attached...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan SimmonsBusiness Analyst IIIAuthor Commented:
That works. Thanks!
Rob HensonFinance AnalystCommented:
Hi Ryan,

You can also achieve that without VBA by using AutoFilter.

Select your data in columns A and B and use the Filter button on the Data tab to add a Filter. Use the dropdown in one of the columns to show Filter Options and from the list at the bottom deselect all entries except Blanks and Click OK; only the blank rows will now be visible.

In the first visible row, lets assume row 3, in column A enter formula =A2 and in column B enter =B2.

Select the extent of your data again, the row numbers down the left hand side will be blue for the filtered range and black for rows beyond the filtered range. Press Ctrl D and the formulas from row 3 will be filled down. This will only affect the visible rows, therefore the existing values won't be overwritten and the formulas will then refer to the relevant cell values as they are copied down.

Deactivate/Remove the filter and Copy paste as values if so required.

This is effectively what the above code does but without the manual filtering. Downside with running VBA is that it deletes any Undo history.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.