Skip to content

Instantly share code, notes, and snippets.

@adam-e-trepanier
Last active October 4, 2017 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam-e-trepanier/008ae6ea714893ba8c8566aa9c377b36 to your computer and use it in GitHub Desktop.
Save adam-e-trepanier/008ae6ea714893ba8c8566aa9c377b36 to your computer and use it in GitHub Desktop.
Public Sub DeleteRowTest()
Dim i As Long
Dim LastRow As Long
Dim Cols As Variant
Dim LookFor As String
Dim rng As Range
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
With ActiveSheet
Cols = Split(ActiveCell.EntireColumn.Address(, False), ":")
On Error Resume Next
Set rng = Columns("M")
On Error GoTo 0
If rng Is Nothing Then Exit Sub
The highlighted code is only searching for case specific letters. I don’t know how to put in a MatchCase false in this. How can I get this to search for the word typed in the input box and not have it be case sensitive?
LookFor = InputBox("Enter Search string", "Row Delete Code", ActiveCell.Value)
Set rng = Nothing
LastRow = .Cells(.Rows.Count, "M").End(xlUp).Row
For i = LastRow To 2 Step -1
If LCase(.Cells(i, "M").Value) <> LCase(LookFor) Then
If rng Is Nothing Then
Set rng = .Rows(i)
Else
Set rng = Union(rng, .Rows(i))
End If
End If
Next i
If Not rng Is Nothing Then rng.Delete
End With
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Range("M2").Select
End Sub
@adam-e-trepanier
Copy link
Author

adam-e-trepanier commented Oct 4, 2017

I think its LCase in vba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment