Macro (existing) to delete all except this meeting .

Sunline

Well-known Member
Joined
Oct 6, 2007
Messages
701
Office Version
  1. 2016
Platform
  1. Windows
Hello all ,

I have this macro that PeterSS wrote for me .

It works perfectly for two other macros I use where I was able to change the
range and case .

It worked originally when range was col V and deleting all except "1", "1"
It also worked originally when range was col O and deleting all except "Mdn"

But I can not get it work in range E and delete all except Matamata .

I am getting yellow highlite in macro as error .

Not sure at all what to change .

Thanks .
Excel Workbook
A
1Sub Del_Rows()
2 Dim lr As Long, lc As Long, i As Long, rws As Long
3 Dim aCol, tmp
4
5 lr = Range("E" & Rows.Count).End(xlUp).Row
6 lc = Cells(1, Columns.Count).End(xlToLeft).Column
7 aCol = Range("E2:E" & lr).Value
8 ReDim tmp(1 To lr - 1, 1 To 1)
9 For i = 1 To lr - 1
10 Select Case UCase(aCol(i, 1))
11 Case "Matamata Raceway"
12
13 Case Else
14 rws = rws + 1
15 tmp(i, 1) = 1
16 End Select
17 Next i
18 If rws > 0 Then
19 Application.ScreenUpdating = False
20 Application.Calculation = xlCalculationManual
21 Application.EnableEvents = False
22 With Range("A2").Resize(lr - 1)
23 .Offset(, lc).Value = tmp
24 .Resize(, lc + 1).Sort Key1:=.Cells(1, lc + 1), _
25 Order1:=xlAscending, Header:=xlNo
26 .Resize(rws).EntireRow.Delete
27 .Offset(, lc).ClearContents
28 End With
29 Application.EnableEvents = True
30 Application.Calculation = xlCalculationAutomatic
31 Application.ScreenUpdating = True
32 End If
33 MsgBox "Done"
34End Sub
Sheet1
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top