+ Reply to Thread
Results 1 to 4 of 4

If cell contains string, clear values from cells in the same row

Hybrid View

  1. #1
    Registered User
    Join Date
    08-30-2019
    Location
    NV, USA
    MS-Off Ver
    2016
    Posts
    5

    If cell contains string, clear values from cells in the same row

    Hi,

    I'm using a table in Excel to track product inventory, and I'd like to build in what seems like a simple function. I have a column for "Stock Level", which will say "Low" if the current stock falls below a preset minimum (or "Out of Stock"), which changes back to "Good" once enough stock is added to our inventory. I have another column, "Status", for tracking the status of items we need to order ("RFQ to vendor . . ."), allowing everyone to see what the status is, when to expect more, etc.

    I'd like to automatically clear the "Status" column when the "Stock Level" column changes to "Good".

    I am a total rookie with VBA, so I've tried running a loop that iterates through each row, and looks for Good in a given column (with the InStr fxn) but no luck!

    Any help is much appreciated.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: If cell contains string, clear values from cells in the same row

    A sheet event macro could certainly do the job but to prepare it correctly we need an Excel sample.
    Can you attach a short one.
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    08-30-2019
    Location
    NV, USA
    MS-Off Ver
    2016
    Posts
    5

    Re: If cell contains string, clear values from cells in the same row

    Here's a sample, 1st sheet is the inventory list, second sheet is where we remove from stock (scan barcode, enter quantity), and similar process for the add to stock sheet. The first sheet is where the macro would be used.

    In case it matters, the macros on the remove and add to stock sheets separate a comma delimited list, and auto selects the next empty cell for scanning.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: If cell contains string, clear values from cells in the same row

    In sheet Inventory List' s code you could put next statement
    Option Explicit
    Private Sub Worksheet_Activate()
    Const SLCol = "H"
    Const StCol = "I"
    Dim I As Integer
        Application.ScreenUpdating = False
        For I = 2 To Cells(Rows.Count, StCol).End(3).Row
            If (Cells(I, SLCol) = "GOOD") Then Cells(I, SLCol) = ""
        Next I
        Application.ScreenUpdating = True
    End Sub

+ 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. VBA to Clear 1 Cell and Clear other cells Formula only
    By oneblondebrow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-17-2017, 12:56 PM
  2. [SOLVED] Find string and clear cell contents to the right
    By Johnatha in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-11-2016, 03:23 PM
  3. [SOLVED] VBA help needed search a text string then clear offset column values
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2015, 03:51 AM
  4. [SOLVED] VBA help needed to find text string, clear cells then add new cell value
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2014, 11:29 AM
  5. if column equals text string clear cells
    By wacky_diva in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-18-2013, 08:59 PM
  6. If one cell chanes values, clear another cells data
    By Lynn Porter in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-08-2013, 05:23 PM
  7. Need a Macro, so that it will search a string and clear the cell and its left cell
    By sibasundar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 08:54 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