+ Reply to Thread
Results 1 to 11 of 11

Unable to create macro that pastes values from one column to adjacent blanks

  1. #1
    Registered User
    Join Date
    09-28-2016
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    26

    Unable to create macro that pastes values from one column to adjacent blanks

    Dear all,

    I'm trying to create a Macro that finds all blanks in a specific column (for instance "column AG") and for each blank in that column pastes the corresponden right value of the adjacent column (for instance "column AH").

    I tried it with a FOR loop on a range adding an IF for cell.Value=vbNullString, but it doesnt work

    Could anyone please post any code which could apply? Thank you very much in advance.

    (I hope I explain it clear)

  2. #2
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Hi,

    What you want to paste into the next column? Is easier for us to check if you'd upload a workbook for us to check.
    Please consider:
    Be polite. Thank those who have helped you.
    Click the star icon in the lower left part of the contributor's post and add Reputation. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Posting code between tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

  3. #3
    Registered User
    Join Date
    09-28-2016
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    26

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Hi IonutC and thanks for you response.

    I need to paste into the blanks of a specific column the adjacent value of the right column.

    Example: A column "G" has a range of values from "G1" to "G10", but only two of them are blanks. For example G3 and G6.

    The Macro should be able to find these two empty cells and paste into them the values from the cell just on the right ( H3 in the case of G3)

    Of course, if H3 is also an empty cell, it will paste nothing :-)

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    try this template

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    7 represents the column G as it is the 7th column and 8 is the column H. You can change these numbers according to your example

  7. #7
    Registered User
    Join Date
    09-28-2016
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    26

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe:

    Please Login or Register  to view this content.

    John

    Thanks a lot for your help, but it seems that your code pastes the values two rows below the adjacent row. In any case it's clear that you're an expert and provide a solution out of my still basic understanding :-P.

    Thank you very much, anyway!
    Last edited by lcgar; 09-28-2016 at 09:04 AM.

  8. #8
    Registered User
    Join Date
    09-28-2016
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    26

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Quote Originally Posted by IonutC View Post
    7 represents the column G as it is the 7th column and 8 is the column H. You can change these numbers according to your example
    It works perfectly, IonutC.

    It takes a bit of time to do the whole loop, as the columns has many rows, but it's perfect.

    Thank you very much!

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Quote Originally Posted by lcgar View Post
    John

    Thanks a lot for your help, but it seems that your code pastes the values two rows below the adjacent row. In any case it's clear that you're an expert and provide a solution out of my still basic understanding :-P.

    Thank you very much, anyway!
    Are you sure you included the comma in the Offset? Refer too red below.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Cool!

    If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
    Also if all is fine, you can click the star icon in the lower left part of the contributor's post and add Reputation.

  11. #11
    Registered User
    Join Date
    09-28-2016
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    26

    Re: Unable to create macro that pastes values from one column to adjacent blanks

    Quote Originally Posted by JOHN H. DAVIS View Post
    Are you sure you included the comma in the Offset? Refer too red below.

    Please Login or Register  to view this content.

    Yes, I did!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 06-15-2016, 09:53 AM
  2. Macro that moves Formulas 1 column right and then Pastes Values into previous column
    By ExcelDavid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 05:30 PM
  3. Macro to find all specific values in column and replace adjacent cell values
    By dblock02 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2013, 06:03 AM
  4. [SOLVED] Create a macro that goes through column J and if value is 2, then deletes adjacent cells
    By elmaco12 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-19-2012, 10:38 AM
  5. Replies: 1
    Last Post: 10-03-2012, 07:06 PM
  6. Replies: 2
    Last Post: 09-05-2012, 03:20 PM
  7. [SOLVED] Automating a macro that copies and pastes data and pastes 2 rows under the previous one.
    By thebank in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2012, 05:02 PM

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