+ Reply to Thread
Results 1 to 4 of 4

Duplicate to adjacent column if that column is blank

  1. #1
    Registered User
    Join Date
    04-13-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    29

    Duplicate to adjacent column if that column is blank

    Dear all,

    I have an easy problem that I can’t seem to get sorted and it’s getting frustrating being so poor at VBA.

    I need a macro that will automatically copy the cell value entered in columns B, D, F, H into the same row, left adjacent column (i.e. columns A, C, E, G respectively) only if those cells are blank.

    E.G.

    When I enter 03/04/2014 into D3
    If C3 is blank then
    C3 = 03/04/2014

    If C3 = 02/04/2014
    then do nothing


    Thanks boffins.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Duplicate to adjacent column if that column is blank

    Copy this code directly onto the worksheet code page (not a module) and change the ranges listed below as needed.

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Duplicate to adjacent column if that column is blank

    Hi,

    A Macro could no doubt be written to do this, but perhaps consider a more pragmatic solution using just functions and helper columns.

    Assuming columns to the right of H are free (and if not temporarily add some and then delete them when this process is finished.

    In say

    I3 enter: =IF(A3="",B3,A3)
    J3: =B3
    K3: =IF(C3="",D3,C3)
    L3: =D3
    M3: =IF(E3="",F3,E3)
    N3: =F3
    O3: =IF(G3="",H3,G3)
    P3: =G3

    Copy these down as necessary. then copy the whole range I3:Pnn and pates it back as Values to A3. Finally if you've added helper columns delete them.

    If you want a macro to do the job I'd be inclined to enshrine the above procedure in the macro.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    04-13-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Duplicate to adjacent column if that column is blank

    Thanks Daffodil,

    That's twice you've helped me out. Much appreciated.

    Richard: Actually, that would have been possible and would be effective. I hadn't considered that... Still, due to the size of my workbook, I'm think I'll go with the VBA solution.

+ 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: 4
    Last Post: 08-11-2013, 12:58 AM
  2. Replies: 1
    Last Post: 06-01-2013, 01:27 AM
  3. Replies: 4
    Last Post: 05-10-2012, 08:16 PM
  4. Replies: 2
    Last Post: 03-28-2012, 11:47 AM
  5. macro to find first blank cell in a column cut the value from left adjacent column
    By willykin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-01-2012, 09:23 AM

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