PDA

View Full Version : [SOLVED:] Shift column from row 3 to left



DaveG93
06-17-2016, 12:45 AM
Hey,

i have a problem again.. :D
I need to delete everything from D4:D2500 and the shift all other columns from row 4 to the left.
Here's what i got so far, but this is not working. Somehow it deletes many columns and I dont get what the macro shifts


Sub löschen()

Range("D4:D2500").Select
Selection.Delete Shift:=xlToLeft

End Sub

mancubus
06-17-2016, 01:49 AM
?


Worksheets("Sheet1").Columns(4).Delete

DaveG93
06-17-2016, 02:04 AM
This doesn't work, since I want to keep the first 3 rows of the sheet :/

mancubus
06-17-2016, 02:49 AM
ah.
you probably recorded the macro in post 1.


actually it should work.

DaveG93
06-17-2016, 06:17 AM
I just tried it with D4:D1999 and it worked...
So the 2500 was probably the reason, but I don't know why
Anyways, it doesn't matter since I'll never have more than 1999 rows

Thanks anyways!

mdmackillop
06-17-2016, 08:04 AM
Somehow it deletes many columns
If you have merged cells intersecting your range it will cause this using your code.


Range("D4:D2500").Select
Selection.Delete Shift:=xlToLeft


Better practice to do the task without selecting, and the issue will not arise. Better still to avoid merged cells. Consider aligning as "Centre across selection"


Range("D4:D2500").Delete Shift:=xlToLeft

mdmackillop
06-17-2016, 08:18 AM
BTW

This doesn't work, since I want to keep the first 3 rows of the sheet :/
This refers to a single column

Worksheets("Sheet1").Columns(4).Delete
This refers to 4 columns.

Worksheets("Sheet1").Columns("A:D").Delete