Results 1 to 4 of 4

VBA - Delete all rows with zero value in particular column

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Question VBA - Delete all rows with zero value in particular column

    Hi,

    I would like to be able to delete all rows of data which have 0.00 in the fifth column. The column header is "Hrs per Position", and the sheet name is "GPT to PlanView Mapping". The number of rows will change from time to time.

    I found the following code, but it is not working for me, and I do not know how to fix it.

    Option 1:

    Sub Format()
    
    Dim Fund As Long 
    Dim TotalLoop As Long
    
    RowCount = Range("A65536").End(xlUp).Row
    For TotalLoop = RowCount To 2 Step -1
    Fund = Cells(TotalLoop, 10)
    If Fund = 0 Then
    Rows(TotalLoop).Delete
    Cells(TotalLoop - 1, 10) = Fund
    End If
    Next TotalLoop
    
    End Sub
    Option 2:
    Sub Format()
    
    Dim sh As Worksheet
    Dim Fund As Long
    Dim TotalLoop As Long
    Set sh = ThisWorkbook.Sheets("Sheet1")
    RowCount = sh.Range("A1", sh.Range("A1").End(xlDown)).Rows.Count
    
    
    For TotalLoop = RowCount To 2 Step -1
    Fund = Cells(TotalLoop, 10)
    If Fund = 0 Then
    Rows(TotalLoop).Delete
    End If
    Next TotalLoop
    
    End Sub
    Any help would be greatly appreciated!!

    Carlos
    Last edited by alansidman; 04-13-2017 at 02:18 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. code to find rows with same value in column C:F and delete the rows
    By bezbid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2016, 09:52 AM
  2. Replies: 2
    Last Post: 02-29-2016, 03:05 PM
  3. [SOLVED] Vba to sum up rows based on column a & b and delete duplicate rows
    By kevivu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2016, 03:15 PM
  4. Macro to keep rows that have certain text in one column, delete rows that do not.
    By mandalope in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2014, 02:35 PM
  5. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  6. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  7. Sort Column, Delete Rows, Delete Column, Move Molumn, more inside?
    By motown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-13-2008, 09:44 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