Results 1 to 3 of 3

VBA delete rows that don't contain the character /

Threaded View

maax555 VBA delete rows that don't... 02-19-2020, 10:33 AM
6StringJazzer Re: VBA delete rows that... 02-19-2020, 12:15 PM
maax555 Re: VBA delete rows that... 02-20-2020, 03:43 AM
  1. #1
    Forum Contributor
    Join Date
    02-29-2012
    Location
    UK, Newcastle
    MS-Off Ver
    Office 365
    Posts
    131

    VBA delete rows that don't contain the character /

    Hi All, i want a VBA code to delete all rows that donot contain the "/" character. So column D contains part numbers in my sheet. We have two formats for part numbers one contains only numbers and the other will always have a / in it.
    I have tried the following code but this deletes all rows, however if i change the value to a specific value that i can see is in my spreadsheet it does delete all rows other than the row with the specific value.
    I was trying to use "*/*" hoping this would search on anything in the cell that contains /.
    the codes is shown below, any help would be appreciated.

    ' Defines variables
    Dim Cell As Range, cRange As Range, LastRow As Long, x As Long
    
    
    ' Defines LastRow as the last row of data based on column E
    LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
    
    
    ' Sets check range as D1 to the last row of D
    Set cRange = Range("D1:D" & LastRow)
    
    
    ' For each cell in the check range, working from the bottom upwards
    For x = cRange.Cells.Count To 1 Step -1
        With cRange.Cells(x)
            ' If the cell does not contain one of the listed values then...
            If .Value <> "*/*" Then
                ' Delete that row
                .EntireRow.Delete
            End If
        End With
    ' Check next cell, working upwards
    Next x
    Last edited by maax555; 02-19-2020 at 11:06 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] delete the rest of the character after found character E
    By oeyandyprawira in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-06-2018, 12:11 AM
  2. [SOLVED] how to delete a character from the character
    By rcahayag1925 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-15-2017, 05:39 AM
  3. [SOLVED] Delete rows that start with the character *
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2015, 04:20 AM
  4. Delete rows if cells have character(s)...
    By elsoung in forum Excel General
    Replies: 8
    Last Post: 10-04-2012, 06:29 PM
  5. [SOLVED] Delete any character after the 7th character
    By plank in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2012, 04:54 AM
  6. VBA Check number of empty rows after a character and add or delete if necessary
    By frjcd in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-08-2012, 06:55 PM
  7. Macro to find character and delete all text in cell after the character
    By SpencerRichman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2012, 06:08 PM

Tags for this Thread

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