Copy and Paste IF Cell in column is empty

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
Hi

I need a code that will copy and paste data from column D to column B if column B is empty, the code will ignore any empty cells in column D and move to the next cell with data to copy over.

From this
ABCD
JANEJANEDOE
JOHNDOEJOHNDOE
JANEJANESMITH
JOHNSMITHJOHNSMITH
JAMES
JILL
JACKJACKJONES

<tbody>
</tbody>


To This

ABCD
JANEDOEJANEDOE
JOHNDOEJOHNDOE
JANESMITHJANESMITH
JOHNSMITHJOHNSMITH
JAMES
JILL
JACKJONESJACKJONES

<tbody>
</tbody>


Hope this makes sense
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Place this formula in B1 and copy down: =IF(D1<>"",D1,"")
If you prefer a macro, please let me know.
 
Upvote 0
How about
Code:
Sub Sharid()
   With Range("B2", Range("A" & Rows.count).End(xlUp).Offset(, 1))
      .SpecialCells(xlBlanks).FormulaR1C1 = "=if(rc[2]<>"""",rc[2],"""")"
      .Value = .Value
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,337
Members
449,218
Latest member
Excel Master

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