+ Reply to Thread
Results 1 to 3 of 3

Clearing only specific text in range

Hybrid View

  1. #1
    Registered User
    Join Date
    03-20-2020
    Location
    toronto
    MS-Off Ver
    excel 2019
    Posts
    43

    Clearing only specific text in range

    Hey everyone,

    I'm stumped. Have a worksheet and assigned a macro button that will clear contents of a specific range. The clear button works but I just want to clear the cells that contain W while leaving the cells that are marked X.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,903

    Re: Clearing only specific text in range

    Option Explicit
    
    Sub ClearW()
        Dim c As Range
        Dim rng As Range
        Dim lr As Long
        lr = Range("A" & Rows.Count).End(xlUp).Row
        Set rng = Range("B2:O" & lr)
        For Each c In rng
            If c = "W" Then c.ClearContents
        Next c
    End Sub
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    03-20-2020
    Location
    toronto
    MS-Off Ver
    excel 2019
    Posts
    43

    Re: Clearing only specific text in range

    works perfectly. Thanks so much!

+ 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. Replies: 1
    Last Post: 09-12-2018, 06:16 AM
  2. Selecting and clearing a Specific Range within an Active Selection
    By AustinR in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-02-2015, 01:19 PM
  3. [SOLVED] VBA to Find Specific Text, then Copy range to next open cell under specific text
    By Remotruker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2015, 10:59 AM
  4. Clear range based on cell value - clearing cells out of specified range
    By CADiphile in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2013, 02:48 PM
  5. Replies: 2
    Last Post: 08-05-2013, 07:32 PM
  6. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM
  7. Display msgbox when specific text entered in specific range
    By Ali_Riza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2012, 08:05 AM

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