Results 1 to 4 of 4

Thread: VBA Excel - If word in this column delete contents from another column
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2019
    Posts
    86
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Excel - If word in this column delete contents from another column

    I'm trying to say; if the word payout is in column c, delete contents from column b. I"m getting an error message @ If (Not Intersect(Target, Rows(3)) Is Payout) And (Target.Count = 3) Then

    Sub Filter1()
    Dim lRow As Long
    Dim ts As Date
    If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
    lRow = ActiveSheet.Range("A30000").End(xlUp).Row



    With Windows("Rental Rec.xlsm")
    Sheets("Owned").Select
    With Range("a2:bh" & lRow)
    .AutoFilter
    .AutoFilter field:=2, Criteria1:="<>#N/A"
    .AutoFilter field:=3, Criteria1:="Payout"

    End With
    End With

    'trying to say; if payout is in column c, delete contents from column b
    ' .Range("b3:b" & lrow).Value = "delete"


    If (Not Intersect(Target, Rows(3)) Is Payout) And (Target.Count = 3) Then
    Range("b3:b" & lRow).ClearContents




    End If

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    23,149
    Post Thanks / Like
    Mentioned
    390 Post(s)
    Tagged
    41 Thread(s)

    Default Re: VBA Excel - If word in this column delete contents from another column

    How about
    Code:
    Sub Filter1()
    Dim lRow As Long
    Dim ts As Date
    
    With Workbooks("Rental Rec.xlsm")
       With .Sheets("Owned")
          If .AutoFilterMode And .FilterMode Then .ShowAllData
          lRow = .Range("A30000").End(xlUp).Row
          With .Range("a1:bh" & lRow)
             .AutoFilter Field:=2, Criteria1:="<>#N/A"
             .AutoFilter Field:=3, Criteria1:="Payout"
          End With
          .AutoFilter.Range.Offset(1).Columns(2).ClearContents
       End With
    End With
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  3. #3
    Board Regular
    Join Date
    Mar 2019
    Posts
    86
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Excel - If word in this column delete contents from another column

    Thank you, worked great,

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    23,149
    Post Thanks / Like
    Mentioned
    390 Post(s)
    Tagged
    41 Thread(s)

    Default Re: VBA Excel - If word in this column delete contents from another column

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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