Consulting

Results 1 to 3 of 3

Thread: if find none numeric data on cloumn A just clean the column A

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    Question if find none numeric data on cloumn A just clean the column A

    I have a VBA code that check column A and if does not find and numeric data it will delete the row , now i need clean only the cell on column A
    Thank you

    Sub CleanRowifnotnumeric()
         'clean a row if it doesn't start with a number
        Dim rng As Range
        Dim cell As Range
         
        Set rng = Range("A1", Range("A" & ActiveSheet.UsedRange.Rows.Count))
        For Each cell In rng
            Debug.Print Cells.Rows.Address
            If IsNumeric(Left(cell.Value, 1)) = False And _
            Left(cell.Value, 1) <> "CH" And _
            Left(cell.Value, 1) <> "ZM" And _
            Left(cell.Value, 1) <> "ZM" _
            Then cell.Rows.Cells.Value.ClearContents
            
        Next cell
    End Sub

  2. #2
    Try this:

    Sub CleanRowifnotnumeric()
    'clean a row if it doesn't start with a number
    Dim rng As Range
    Dim cell As Range

    Set rng = Range("A1", Range("A" & ActiveSheet.UsedRange.Rows.Count))
    For Each cell In rng
    Debug.Print Cells.Rows.Address
    If IsNumeric(Left(cell.Value, 1)) = False And _
    Left(cell.Value, 1) <> "CH" And _
    Left(cell.Value, 1) <> "ZM" And _
    Left(cell.Value, 1) <> "ZM" _
    Then cell.ClearContents

    Next cell
    End Sub

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Thank you very much for your big help , it is work very well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •