Consulting

Results 1 to 6 of 6

Thread: Clean the row if column F does not contain UDS or EUR

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

    Question Clean the row if column F does not contain UDS or EUR

    Heloo
    I need a VBA code that check column F and if it will not find USD or EUR or CAD on this column clean the row also data on column F .i need clean not delete.
    thank you

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    roughly:
    For each Cel in Range("F1:F" & LastRow)
    If not (Cel ="USd" OR Cel = EUr" or Cel = "Cad") Then
    Cel.EntireRow.ClearContents.

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Dear smaT
    I used the below code but does not work
    Sub wewe()
    For Each Cel In Range("F1:F" & LastRow)
    If Not (Cel = "USD" Or Cel = "EUR" Or Cel = "TL") Then
    Cel.EntireRow.ClearContents
    End If
    Next
    End Sub

  4. #4
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    I used this code and it is work

    Sub deleterows()
    
    Dim intcount As Integer
    Dim introw As Integer
    
    intcount = ActiveSheet.UsedRange.Rows.Count
    
    For introw = intcount To 1 Step -1
        If Not Range("D" & introw) = "USD" Or Range("D" & introw) = "EUR" Or Range("D" & introw) = "CAD" Then
        Range("D" & introw).EntireRow.ClearContents
        End If
    
    Next
    
    End Sub

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Excellent work.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Never mind -- had it backwards
    Last edited by Paul_Hossler; 09-02-2014 at 07:21 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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