Hi
I am a newbie to macros, and this is my first post to this group.
I am trying to move columns in an excel, and hitting error 1004.
This is the relevant portion of code:
Can someone help me resolve this?Columns(FoundAtColName & ":" & FoundAtColName).Select Selection.Cut Columns(Chr(Asc(p_dest_col) + 1) & ":" & Chr(Asc(p_dest_col) + 1)).Select Selection.Insert Shift:=xlToRight Application.CutCopyMode = False
Thanks in advance
Ajay
Last edited by Paul; 03-11-2010 at 12:11 PM.
Ajaykgarg, Welcome to the forum
At least you tried to make your code look good, but please use # in the advanced editor so your post applies to the Forum rules.
Edit your post by selecting your code, press the # sign in the advanced editor
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Ricardo
I have done that.
Do you have an answer to my q please?
This will get you in troubleWhen columns exceed Z. e.g AA till IVColumns(Chr(Asc(p_dest_col) + 1) & ":" & Chr(Asc(p_dest_col) + 1)).Select
Please use R1C1 style (for columns 1 to 256) as all functions like cells.columns.count work that way.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
I have changed that. Thanks for saving my life.![]()
I have chnged my code as follows. I am not getting the error now:-
Columns(Search_Range.Column).Cut If Search_Range.Column > DestColNum Then Columns(p_dest_col).Insert Else Columns(DestColNum + 1).Insert End If Application.CutCopyMode = False
Last edited by ajaykgarg; 03-21-2010 at 05:05 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks