+ Reply to Thread
Results 1 to 7 of 7

VBA code to move data to a cell only if not blank

  1. #1
    Registered User
    Join Date
    04-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2007
    Posts
    20

    VBA code to move data to a cell only if not blank

    I need to move the contents from column E to Column H only if column E has data. If not the text in column H needs to stay. Can anyone help me?

    thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: VBA code to move data to a cell only if not blank

    Try

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: VBA code to move data to a cell only if not blank

    This doesn't seem to work....I entered as below
    Please Login or Register  to view this content.
    Last edited by joannakf; 05-14-2012 at 09:54 AM.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: VBA code to move data to a cell only if not blank

    Question >> do you have phone numbers in column E that you want to move to column H, but only if column H is currently blank, or do you want to move the phone number when the user enters it in column E and not column H?
    Last edited by jeffreybrown; 05-14-2012 at 10:04 AM.
    HTH
    Regards, Jeff

  5. #5
    Registered User
    Join Date
    03-14-2012
    Location
    Galway, Ireland
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: VBA code to move data to a cell only if not blank

    Hi im pretty new to all this and not sure if this will help but from what I understand this should help.

    Please Login or Register  to view this content.
    You could probably change this to cut instead of copy.
    This is for a button but it would be pretty easy to do it so it runs if there is something entered into E4.

    Sorry understand what you wanna do now this wouldn't really help.
    Last edited by Irish RayRay; 05-14-2012 at 10:22 AM.

  6. #6
    Registered User
    Join Date
    04-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: VBA code to move data to a cell only if not blank

    The phone numbers will only show up either in column E or H, not both. So I want to move the phone numbers in column E to column H anytime they show up in column E, column H will always be blank when this occurs. So it could be written either way you mention above.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: VBA code to move data to a cell only if not blank

    The code JieJenn supplied works for me.

    When you say it didn't work, what happened? Any error? If an error, did you get a debug and if you hit debug what does it highlight?

    Also, the code supplied uses column A to look for the last row. Is this row populated as in your example?

+ 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