+ Reply to Thread
Results 1 to 4 of 4

VBA to clear contents of the cell in a column of data in a cell starts with specific word.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    118

    VBA to clear contents of the cell in a column of data in a cell starts with specific word.

    VBA to clear contents of the cell in a column of data in a cell starts with specific word.


    Have to clear the contents of all those cells in a coloumn which starts from "Property ID"
    Have attached the excel file where data and needed result is mentioned.
    Attached Files Attached Files
    Last edited by winmaxservices1; 01-03-2015 at 08:00 AM. Reason: additional information

  2. #2
    Valued Forum Contributor
    Join Date
    03-28-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    702

    Re: VBA to clear contents of the cell in a column of data in a cell starts with specific w

    HI winmax,

    You may try this,

    Sub ClearContents()
    Dim rng As Range
    
        For Each rng In Range("A2:A24")
        
            If Left(rng, 11) = "Property ID" Then
                rng.Value = ""
            End If
        Next rng
    End Sub
    Please add my reputation if the above code has solved your problem

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: VBA to clear contents of the cell in a column of data in a cell starts with specific w

    Hi, winmaxservices1,

    use the Autofiloter and "Starts with" to filter and delete the rows/entries manually.

    As your data shows empty cells next to the searched words you may like to use
    Sub EF1058181()
    On Error Resume Next
    Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End Sub
    Sub EF1058181_2()
    On Error Resume Next
    Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Offset(0, -1).ClearContents
    End Sub
    Ciao,
    Holger
    Last edited by HaHoBe; 01-03-2015 at 08:26 AM. Reason: code for both deleting entire row as well as clearing cells
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: VBA to clear contents of the cell in a column of data in a cell starts with specific w

    You may try this..
    Sub ClearCells()
    With Range("A:A")
        .AutoFilter field:=1, Criteria1:="Property ID*"
        .SpecialCells(xlCellTypeVisible).Cells.ClearContents
        .AutoFilter
    End With
    End Sub
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Clear contents in specific cell and the cells in the next 2 columns to the right
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2014, 01:25 AM
  2. [SOLVED] move down column and for every blank cell, clear contents of cell to the left
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2014, 11:23 AM
  3. [SOLVED] Clear contents of specific cells on the same row if a specific cell on that row is empty
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2014, 01:48 PM
  4. [SOLVED] remove cell contents if contains certain word in a specific column
    By picton2000 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-30-2013, 05:09 PM
  5. Delete rows or Clear contents below a specific word is found in Column A
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2012, 04:08 PM

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