+ Reply to Thread
Results 1 to 6 of 6

1004 This selection is not valid.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    1004 This selection is not valid.

    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:

    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
    Can someone help me resolve this?

    Thanks in advance
    Ajay
    Last edited by Paul; 03-11-2010 at 01:11 PM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: 1004 This selection is not valid.

    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

  3. #3
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: 1004 This selection is not valid.

    Ricardo

    I have done that.
    Do you have an answer to my q please?

  4. #4
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: 1004 This selection is not valid.

    This will get you in trouble
    Columns(Chr(Asc(p_dest_col) + 1) & ":" & Chr(Asc(p_dest_col) + 1)).Select
    When columns exceed Z. e.g AA till IV

    Please use R1C1 style (for columns 1 to 256) as all functions like cells.columns.count work that way.

  5. #5
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: 1004 This selection is not valid.

    I have changed that. Thanks for saving my life.

  6. #6
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: 1004 This selection is not valid.

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1