Thanks. Works fine. I have in the past been able to do a simple copy and paste using code like this:The syntax for cutting the data from column A to column B is incorrect. Try using the following code:
For Each Cell In Range("A2:A33") If Cell.Value <> "" Then Cell.Cut Destination:=Cell.Offset(0, 1) Next
This will loop through each cell in the range A2:A33, check if the cell is not empty, and then cut the contents of the cell and paste it into the cell to the right of it.
Range(ActiveCell, ActiveCell).Cut Destination:=Range(ActiveCell, ActiveCell).Offset(1, 0)
ActiveCell.Value.Cut Destination:=ActiveCell.Offset(1, 0)
For Each Cell In Range("A2:A33")
If Cell.Value <> "" Then
Cell.Value.Cut Destination:=Cell.Offset(0, 1)
End If
Next
Thanks. I just thought my 'simpler' code might work. No big deal. Have a great night!Range(ActiveCell, ActiveCell).Copy is used to copy the content of a single active cell and paste it to another location.
To use the Cut method instead of Copy, you would need to use a similar syntax, like this:
VBA Code:Range(ActiveCell, ActiveCell).Cut Destination:=Range(ActiveCell, ActiveCell).Offset(1, 0)
You can also use the Cut method on the Value property of a cell, like this:
Code:ActiveCell.Value.Cut Destination:=ActiveCell.Offset(1, 0)
Please note that, unlike the Copy method, the Cut method will remove the content from the source cell after it is pasted to the destination cell.
Also you can move the data in column A to column B:
This code loops through each cell in the range A2:A33. If the cell is not empty, it cuts the value and pastes it to the cell in the same row but in column B.Code:For Each Cell In Range("A2:A33") If Cell.Value <> "" Then Cell.Value.Cut Destination:=Cell.Offset(0, 1) End If Next
Thank you Sinoyon780. i've been looking for this answer for several hours.Range(ActiveCell, ActiveCell).Copy is used to copy the content of a single active cell and paste it to another location.
To use the Cut method instead of Copy, you would need to use a similar syntax, like this:
VBA Code:Range(ActiveCell, ActiveCell).Cut Destination:=Range(ActiveCell, ActiveCell).Offset(1, 0)
You can also use the Cut method on the Value property of a cell, like this:
Code:ActiveCell.Value.Cut Destination:=ActiveCell.Offset(1, 0)
Please note that, unlike the Copy method, the Cut method will remove the content from the source cell after it is pasted to the destination cell.
Also you can move the data in column A to column B:
This code loops through each cell in the range A2:A33. If the cell is not empty, it cuts the value and pastes it to the cell in the same row but in column B.Code:For Each Cell In Range("A2:A33") If Cell.Value <> "" Then Cell.Value.Cut Destination:=Cell.Offset(0, 1) End If Next