Moving data from Col B to Col A

  • Thread starter Thread starter Michael Koerner
  • Start date Start date
M

Michael Koerner

I need to move the data from Col B to Col A only if the cell in Col A is empty.
Is there an easy way to do this?
 
Hi Michael,

try:

For i = 1 To 65532

If Range("a" & i).Value = "" Then Range("a" & i).Value =
Range("b" & i)
End If

Next i

Best

Markus
 
or, if the cells are really empty/blank, a quicker approach would be

Sub ABCD()
dim cell as Range
On Error Resume Next
for each cell in Activesheet.columns(1).Specialcells(xlBlanks)
cell.Value = Cell.offset(0,1).Value
' uncomment the next line if you want
' the value in B cleared
'cell.Offset(0,1).ClearContents
Next
if err <> 0 then
msgbox "No Blank Cells
err.clear
End if
End Sub
 
Tom I tried your macro, and all I got was the message "No blank Cells

--

Regards
Michael Koerner


or, if the cells are really empty/blank, a quicker approach would be

Sub ABCD()
dim cell as Range
On Error Resume Next
for each cell in Activesheet.columns(1).Specialcells(xlBlanks)
cell.Value = Cell.offset(0,1).Value
' uncomment the next line if you want
' the value in B cleared
'cell.Offset(0,1).ClearContents
Next
if err <> 0 then
msgbox "No Blank Cells
err.clear
End if
End Sub
 
That means they must not actually be blank. Do you have formulas in them
(not blank). Or did you clear them by hitting the spacebar (not blank).

I ran it on a sheet that actually had blank cells in column A and it worked
perfectly.

Guess you will have to clean up your data or go with Markus's code.
 
Your absolutely correct. Once I cleared the contents of the supposedly blank
cells your macro worked as advertised. Which is good, as I wouldn't know how to
use Markus's code <g>

--

Regards
Michael Koerner


That means they must not actually be blank. Do you have formulas in them
(not blank). Or did you clear them by hitting the spacebar (not blank).

I ran it on a sheet that actually had blank cells in column A and it worked
perfectly.

Guess you will have to clean up your data or go with Markus's code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top