+ Reply to Thread
Results 1 to 3 of 3

Formula to move data to Left when LEFT cell is blank?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2019
    Location
    Sac
    MS-Off Ver
    2010
    Posts
    1

    Formula to move data to Left when LEFT cell is blank?

    I have four cells that I use to track items. Sometimes all cells are used and sometimes only a few. I would like help in how I can automate a move in data in a cell that is RIGHT of an empty cell move to the LEFT. (i.e.) I fill cells C5, D5, E5, & F5. I then delete the data in cell D5 and want to have the data in E5 move to D5, and F5 move to E5....leaving F5 empty for the new data. kind-of like right justify. Thank you.

  2. #2
    Valued Forum Contributor PaulSP8's Avatar
    Join Date
    11-21-2017
    Location
    Chorley, England
    MS-Off Ver
    2013 & 2021
    Posts
    437

    Re: Formula to move data to Left when LEFT cell is blank?

    I don't think you can do this with a Formula, you'll be needing VBA.

    Something like;

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Not Intersect(Target, Range("C:G")) Is Nothing Then
        Application.ScreenUpdating = False
        
        For Each cel In Target
            myRow = cel.Row
            myCol = cel.Column
        
            For x = myCol To 7
                If Cells(myRow, myCol).Value = "" Then
                    If Cells(myRow, myCol + 1).Value <> "" Then
                        Cells(myRow, myCol).Value = Cells(myRow, myCol + 1).Value
                        Cells(myRow, myCol + 1).Value = ""
                    End If
                End If
            Next x
        Next cel
    
        Application.ScreenUpdating = True
        
    End If
    End Sub
    Put that in the Worksheet code - It'll check columns C through G for changes, if it finds a blank cell it'll move all the values to the right along to the left.

    Post back if you need more help

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Formula to move data to Left when LEFT cell is blank?

    Moved to the appropriate forum section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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. Delete blank cells and move data to left
    By DRS2016 in forum Excel General
    Replies: 10
    Last Post: 04-19-2017, 06:27 PM
  2. [SOLVED] Macro to move data to the left when there are blank cells.
    By daisiedawn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2016, 06:15 PM
  3. [SOLVED] Function to move text data to left blank cell
    By Karnik in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-12-2016, 08:03 PM
  4. [SOLVED] move down column and for every blank cell, clear contents of cell to the left
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2014, 11:23 AM
  5. [SOLVED] Move data row by row to left hand side of an array across blank cells
    By Fred99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-11-2012, 06:34 PM
  6. cell data move to left
    By lapot in forum Excel General
    Replies: 3
    Last Post: 05-18-2007, 08:04 PM

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