+ Reply to Thread
Results 1 to 4 of 4

How do I insert a column without pasting from the clipboard?

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 365
    Posts
    36

    How do I insert a column without pasting from the clipboard?

    I'm using Excel 2010 in 97-2003 compatibility mode.

    I open up a csv file separately then copy data to the clipboard. Then I switch to my master file and run the macro. I want the macro to simply insert a blank column, but as well as this it keeps pasting in the copied data for some reason. This is the code that doesn't work properly:

    Sheets("master").Select
    Columns("p:p").Select
    Selection.EntireColumn.Insert

    Is there a version of this insert command that doesn't paste data from the clipboard?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: How do I insert a column without pasting from the clipboard?

    Hi

    that's odd - are you sure there is no other code in your macro that is causing it to paste the data?

    alternatively you yould try this:

    Please Login or Register  to view this content.
    but I'm not sure it will give a different result

  3. #3
    Registered User
    Join Date
    11-26-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 365
    Posts
    36

    Re: How do I insert a column without pasting from the clipboard?

    Same result. I tried it on a different pc (the one it's intended for that's running Excel 2007) but I get the same thing there as well. It's right at the start of the macro, like so:

    'update sheet
    Sub UpdateSheet()

    Sheets("master").Select
    Columns("p:p").Select
    Selection.EntireColumn.Insert

    'get first row on data sheet
    f1 = 2
    Do Until Sheets("data").Cells(f1, 1) > Int(Sheets("data").Cells(1, 11)) - 1
    f1 = f1 + 1
    Loop

    ... etc


    I'm pretty stumped with this. I could work out some kind of workaround but I'd like to know what's going on.

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: How do I insert a column without pasting from the clipboard?

    hi

    can you post the whole macro - it might be easier to spot if the problem lies elsewhere

    alternatively, try putting in an "End" after Selection.EntireColumn.Insert and see if the macro has copied the data in at this point

    also - can I suggest you add code tabs, or a moderator will ping you! (click "edit post", select the code and click the hash symbol from the bar)

+ 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