+ Reply to Thread
Results 1 to 5 of 5

delete columns and rows based on zero or empty values and create new file

  1. #1
    Forum Contributor
    Join Date
    11-14-2021
    Location
    africa
    MS-Off Ver
    2016 & 2019
    Posts
    255

    delete columns and rows based on zero or empty values and create new file

    Hello
    I want deleting columns C,F and delete whole rows if the columns D,E contain zero or empty values , then should delete the whole row
    when deletion should create new file as xlsx in the same folder where the source file is in and rename REPORT FINAL & date,format("dd\mm\yyyy) with keeping orginal data in file source and should replace the file if the same file is already existed
    thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to your attachment an Excel / VBA basics demonstration for starters to paste only to the source SH1 worksheet module :

    PHP Code: 
    Sub Demo1()
        
    Dim BILL$, Wb As WorkbookL&
            
    BILL "REPORT FINAL" Format(Date" DD-MM-YYYY ") & ".xlsx"
        
    For Each Wb In Workbooks
              
    If Wb.Name BILL Then Wb.Close FalseSet Wb Nothing: Exit For
        
    Next
            Workbooks
    .Add xlWBATWorksheet
        With ActiveSheet
            
    [A1,B1,D1,E1].Copy .[A1]
            [
    K2].Formula "=D2+E2>0"
            
    [A1].CurrentRegion.AdvancedFilter 2, [K1:K2], .[A1:D1]
            [
    K2].Clear
            L 
    = .[A1].CurrentRegion.Rows.Count 1
            
    If L Then .[A2].Resize(L) = Evaluate("ROW(1:" ")")
           .
    Name Name
            BILL 
    ThisWorkbook.Path "\" & BILL
            If Dir(BILL) > "" Then Kill BILL
           .SaveAs BILL, 51
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 10-30-2022 at 09:06 AM. Reason: little tweak ...

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: delete columns and rows based on zero or empty values and create new file

    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Contributor
    Join Date
    11-14-2021
    Location
    africa
    MS-Off Ver
    2016 & 2019
    Posts
    255

    Re: delete columns and rows based on zero or empty values and create new file

    all of codes work as I expected .
    many thanks guys

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: delete columns and rows based on zero or empty values and create new file

    Glad to have contributed...Tx for rep +

+ 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. how to delete rows based on the certain values in several columns
    By nazaninibb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2018, 07:00 AM
  2. create a table based on values selected in rows and columns
    By hemagala in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2015, 03:46 AM
  3. Replies: 2
    Last Post: 04-02-2015, 12:27 PM
  4. Delete Empty Rows and empty columns from the word table
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 10:51 AM
  5. [SOLVED] Delete rows when two columns are empty
    By Musoguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-29-2013, 09:00 AM
  6. how to delete empty rows or columns only
    By tallercheetah in forum Excel General
    Replies: 3
    Last Post: 02-02-2012, 10:44 AM
  7. Macro to delete entire rows based values in columns
    By shamade2107 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2009, 11:17 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