+ Reply to Thread
Results 1 to 6 of 6

Need macro to conditionally delete and shift cells

Hybrid View

  1. #1
    Registered User
    Join Date
    06-20-2014
    Location
    Indiana, USA
    MS-Off Ver
    2013
    Posts
    10

    Question Need macro to conditionally delete and shift cells

    I have a very large spreadsheet that the data was not entered in the proper cell for approx 250,000 records.

    What I am looking for is a macro that will check the cell value in column, if it is blank or contains Y or just spaces to delete the cell and shift the cells left.

    Column names are:
    1. First
    2. Last
    3. Suffix
    4. Licensed
    5. Email

    Essentially I do not need Licensed column and I want to move all the emails over to that column and will later rename it. However, as stated previously, data entry entered the email in the Licensed column for a multitude of rows.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need macro to conditionally delete and shift cells

    This is a duplicate of http://www.excelforum.com/excel-form...ml#post3764373

    Please read the Rules, and don't post duplicate threads.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    06-20-2014
    Location
    Indiana, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: Need macro to conditionally delete and shift cells

    Attached is an example...

    After running the macro, it should be similar to row 6. Containing data in only the first 4 columns if applicable.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-20-2014
    Location
    Indiana, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: Need macro to conditionally delete and shift cells

    Yeah, I reported myself for it and requested the delete of the one posted in formula and functions. I will post an example spreadsheet here.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need macro to conditionally delete and shift cells

    Try:
    Sub foo()
    Dim lRow As Long
    
    With Sheet1
        For lRow = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
            If InStr(.Cells(lRow, 4).Value, "@") = 0 And InStr(.Cells(lRow, 5).Value, "@") > 0 Then
                .Cells(lRow, 4).Value = .Cells(lRow, 5).Value
            End If
        Next lRow
        .Columns(5).Delete
    End With
    End Sub

  6. #6
    Registered User
    Join Date
    06-20-2014
    Location
    Indiana, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: Need macro to conditionally delete and shift cells

    Thanks this did the trick!

+ 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. [SOLVED] Delete cells when value in cell = 0 and shift up following cells (macro)
    By sandi3006 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2014, 10:24 AM
  2. macro to concatenate, delete and shift cells
    By three_jeeps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2011, 02:27 PM
  3. Delete cells and shift up
    By smiso24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-07-2009, 03:51 PM
  4. Macro to Delete Conditionally Formatted Cells
    By luckylindy345 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2008, 09:07 AM

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