Last active
October 4, 2017 17:21
-
-
Save adam-e-trepanier/008ae6ea714893ba8c8566aa9c377b36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think its LCase in vba