+ Reply to Thread
Results 1 to 8 of 8

Find Inserted Column - Paste Into

  1. #1
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    Find Inserted Column - Paste Into

    I want to append to this macro below so that it will know to paste data into a column that I just inserted in worksheet “Count”. In the macro below I put Column G, but the new column I insert won’t always be Column G. In other words, assume I just inserted a new column in worksheet “Count”. I would like to make the macro know to paste what I copied from worksheet “Number” into Rows 4:20 of that new Column in worksheet “Count” whatever column it may be. Can you assist me with this?

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Find Inserted Column - Paste Into

    Hi Buddy

    On your worksheet "Count", will there ever be any other empty columns aside from the one you've just inserted?

    Dion

  3. #3
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Find Inserted Column - Paste Into

    Yes, but they will all be a couple columns over to the right. The newly inserted column will always be sandwich between columns with data in them.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Find Inserted Column - Paste Into

    Are you manually inserting this column? If a macro is doing it, the macro can store where the blank column is.

    To clarify mojo's question, this blank column will ALWAYS be the first blank column in the data?

    If so, maybe this:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-16-2009 at 01:01 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Find Inserted Column - Paste Into

    My apologies for the delay, yes a macro is inserting the blank column, how can I get the macro to store where the blank column is?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Find Inserted Column - Paste Into

    The post above shows how to directly insert the new data into the next blank column.

    Here's a way to do that by first determining the next column (NC) in a variable:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Find Inserted Column - Paste Into

    The contents are getting pasted into Column A instead of the newly inserted column or I am getting an error message. Any input is appreciated. Maybe I am making a mistake.

    In this code, I have the data going into Column A.

    Please Login or Register  to view this content.
    In the code below, I am getting an error message and this line of code is being highlighted. Sheets("Total").Range("A1").End(xlToRight).Offset(3, 1).PasteSpecial (xlPasteValues)

    Please Login or Register  to view this content.

    Sorry if its my fault. Thanks for your help.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Find Inserted Column - Paste Into

    First there's an error. NC should equal .Column + 1, not .Row
    Please Login or Register  to view this content.
    [/code]
    Rookie mistake, my apologies.

    As for your second line of code, I don't use that offset syntax, nor the way you're using xlpastevalues. Does fixing my error above allow you to use the code I gave you? My code attempts to paste the copied cell into the the next empty column starting in row4. It should work with the fix above.

+ 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