Delete cell and move to next

R

Robert

Hi all
Can anyone help with a macro.
It is supposed to check if the cell in column A is empty and if it is
delete and move the contents of B into A on deletion.
I would post my workings but am too ashamed to do so.
Please help.

Rob
 
B

Bernie Deitrick

Rob,

Not sure if you mean any cell in column A, and by move whether you want to
shift everything over. You could use:

Sub Macro1()
On Error Resume Next
Columns("A:A").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
End Sub

which would do all cells at once, and shift everything over by one cell
whereever there is a blank.

If it is just a few cells that you want to check, then you could do:

Sub Macro1()
On Error Resume Next
Range("A2:A10").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
End Sub

HTH,
Bernie
MS Excel MVP
 
R

Robert

Bernie
I tried the macros' without luck.
I apologise for not explaining myself clearly and will try again
If I have the following:
A B
1 a q
2 b
3 c t

The macro will examine each of the cells in column A and where it finds
a blank (A2) move the contents of B2 into A2.

Thanks in advance

Rob
 
Top