+ Reply to Thread
Results 1 to 3 of 3

PasteSpecial problem in Excel 2002

  1. #1

    PasteSpecial problem in Excel 2002

    Hi group,

    I'm having a problem with PasteSpecial..it always shows me an error at
    this point..what am i doing wrong here?

    Sub InsertColumn()

    For i = 20 To 1 Step -1
    Columns(i).Select
    Selection.Copy
    ' Columns(i).Insert
    Columns(51 - i).Select
    ActiveSheet.PasteSpecial Paste:=xlPasteValues,
    Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    Next i
    Application.CutCopyMode = False

    End Sub


  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    It is because it is one line, and you are putting it on 2.
    Should be:

    Sub InsertColumn()

    For i = 20 To 1 Step -1
    Columns(i).Select
    Selection.Copy
    ' Columns(i).Insert
    Columns(51 - i).Select
    ActiveSheet.PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    Next i
    Application.CutCopyMode = False

    End Sub

    I have put a continuation character.

    Mangesh

  3. #3
    Nigel
    Guest

    Re: PasteSpecial problem in Excel 2002

    The following modified version works for me in xl2002

    Sub InsertColumn()
    Dim i As Integer
    For i = 20 To 1 Step -1
    Columns(i).Copy
    Columns(51 - i).PasteSpecial Paste:=xlPasteValues
    Next i
    End Sub

    --
    Cheers
    Nigel



    <[email protected]> wrote in message
    news:[email protected]...
    > Hi group,
    >
    > I'm having a problem with PasteSpecial..it always shows me an error at
    > this point..what am i doing wrong here?
    >
    > Sub InsertColumn()
    >
    > For i = 20 To 1 Step -1
    > Columns(i).Select
    > Selection.Copy
    > ' Columns(i).Insert
    > Columns(51 - i).Select
    > ActiveSheet.PasteSpecial Paste:=xlPasteValues,
    > Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    > Next i
    > Application.CutCopyMode = False
    >
    > End Sub
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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