+ Reply to Thread
Results 1 to 6 of 6

VBA that looks up a string (or part of) value and deletes the cell

  1. #1
    Registered User
    Join Date
    06-08-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    12

    VBA that looks up a string (or part of) value and deletes the cell

    Hi guys!

    My issue is that I have a spreadsheet with a rather large amount of cells containing different values. (Numbers, text, dates, etc.).

    What I need to do is search through all cells in this big data-set (A1:Z1000), and delete everything in all cells that begin with the text-string "Hour Text".

    With my limited knowledge of VBA, I've been able to get everything right, except for the "search" part.

    Any of you know how to get excel to search through all cells in that given array?

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA that looks up a string (or part of) value and deletes the cell

    Add a filter to the column, filter each column on contains and that text, then delete the visible rows.

    Or add a helper column with a formula of =COUNTIF(A2:Z2,"Hour Text*")>0, and filter that column on TRUE and delete all visible rows.

    No VBA required.

  3. #3
    Registered User
    Join Date
    06-08-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: VBA that looks up a string (or part of) value and deletes the cell

    Hi Bob

    Thanks for the quick reply!

    I'm sry. I probably didn't explain myself well enough.

    The cells that I need to delete are not orderly placed in a single row or column. But distributed all over the spreadsheet with no apparent pattern.

    Hence the need for some function/VBA that goes through each individual cell, and deletes it if it begins with the text "Hour Text". (And the "Hour Text" are only the common beginning of what the cells contain. After that each of the cells contain an 8 digit number that changes with each cell.).

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: VBA that looks up a string (or part of) value and deletes the cell

    first check simple one:
    Please Login or Register  to view this content.
    if not works as expected, we will drill the subject down

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA that looks up a string (or part of) value and deletes the cell

    Quote Originally Posted by gaia View Post
    Hi Bob

    Thanks for the quick reply!

    I'm sry. I probably didn't explain myself well enough.

    The cells that I need to delete are not orderly placed in a single row or column. But distributed all over the spreadsheet with no apparent pattern.

    Hence the need for some function/VBA that goes through each individual cell, and deletes it if it begins with the text "Hour Text". (And the "Hour Text" are only the common beginning of what the cells contain. After that each of the cells contain an 8 digit number that changes with each cell.).
    My response still applies.

  6. #6
    Registered User
    Join Date
    06-08-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: VBA that looks up a string (or part of) value and deletes the cell

    Thank you Kaper!

    That was amazing. Worked like a charm!

    Sry Bob. But as I have to do this on a weekly basis. I would rather not have to do all that stuff manually every single time.

    Thx for the help both of u!

+ 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: 9
    Last Post: 11-14-2005, 05:20 PM
  2. Replies: 3
    Last Post: 11-13-2005, 09:55 PM
  3. [SOLVED] Move Part of Cell String
    By tom in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-13-2005, 02:05 PM
  4. [SOLVED] select part of a cell value string
    By rich_j_h in forum Excel General
    Replies: 2
    Last Post: 05-19-2005, 07:06 AM
  5. [SOLVED] Excell deletes 0 when its the first number in a string
    By dustin1138 in forum Excel General
    Replies: 2
    Last Post: 05-07-2005, 05:06 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