+ Reply to Thread
Results 1 to 8 of 8

Zero Find And Delete

Hybrid View

  1. #1
    Registered User
    Join Date
    04-02-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    96

    Zero Find And Delete

    Hey all,

    I currently have this code:

    Sub zerofind()
    '
    ' zerofind Macro
    '
    Dim LastRow As Long, n As Long
         
        LastRow = Range("B65536").End(xlUp).Row
        For n = LastRow To 1 Step -1
            If Cells(n, 2).Value = 0 Then Cells(n, 2).EntireRow.Delete
            Next n
    '
    End Sub
    Rather than deleting the entire row, I only want to delete the first three cells in that row.

    Help would be greatly appreciated.

    Thanks

    Jamer
    Last edited by jamer02; 07-18-2011 at 08:53 AM.

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Zero Find And Delete

    try this:
    Cells(n, 2).Resize(1,3).Delete

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Zero Find And Delete

    If you mean cols BCD:
    If Cells(n, 2).Value = 0 Then Cells(n, 2).Resize(,3).Delete
    Use Clear instead of Delete if you just want to remove the cells' contents.

  4. #4
    Registered User
    Join Date
    04-02-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    96

    Re: Zero Find And Delete

    No I mean cols ABC

    Cheers

  5. #5
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Zero Find And Delete

    in that case:
    Cells(n, 1).Resize(1,3).Delete

  6. #6
    Registered User
    Join Date
    04-02-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    96

    Re: Zero Find And Delete

    For some reason that is deleting colums BCD still :/

    Any ideas?

  7. #7
    Registered User
    Join Date
    04-02-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    96

    Re: Zero Find And Delete

    Actually, when I have another value in that row, it is moving that value accross.

    Why is this do you think? And is there a solution?

  8. #8
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Zero Find And Delete

    you should use Clear instead of delete as StephenR said
    Cells(n, 1).Resize(1,3).Clear

+ 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