K
Kirk A
Looking for help in trying to use a variable to allow calling the sam
sub from another in different places.
I have a project where I need to delete rows where the value of cell A
is one of the following (Abstract, Title, or Topic). I have copied th
same code 3 different times changing the value for that cell in th
sub. I know that this is inefficient.
The code is as follows:
Sub xdeleteRows()
Dim r As Long
Dim c As Range
Dim Rng As Range
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For r = Rng.Rows.Count To 1 Step -1
If Cells(r, "A").Value = "Abstract:" Then
Rng.Rows(r).EntireRow.Delete
End If
Next r
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
The issue is with this line: If Cells(r, "A").Value = "Abstract:" The
How can I code in a variable for the value, so that depending on wha
stage of the main Sub I am in, I can delete specific rows using
variable?
Thanks
Kir
sub from another in different places.
I have a project where I need to delete rows where the value of cell A
is one of the following (Abstract, Title, or Topic). I have copied th
same code 3 different times changing the value for that cell in th
sub. I know that this is inefficient.
The code is as follows:
Sub xdeleteRows()
Dim r As Long
Dim c As Range
Dim Rng As Range
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For r = Rng.Rows.Count To 1 Step -1
If Cells(r, "A").Value = "Abstract:" Then
Rng.Rows(r).EntireRow.Delete
End If
Next r
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
The issue is with this line: If Cells(r, "A").Value = "Abstract:" The
How can I code in a variable for the value, so that depending on wha
stage of the main Sub I am in, I can delete specific rows using
variable?
Thanks
Kir