jmckeone
Well-known Member
- Joined
- Jun 3, 2006
- Messages
- 550
There are certain recurring tasks I do and rather than have to write new code each time I'm thinking it would be more efficient to have generic code and have the code prompt the user for input to tailor the code to the current application.
For example convert following code so that each place VARIABLE appears that the value could be supplied by the user via inputbox.
For example convert following code so that each place VARIABLE appears that the value could be supplied by the user via inputbox.
Code:
Sub RemoveRows()
Dim NumRows, iLine As Integer
'Select the usedRange
ActiveSheet.UsedRange.Select
'Get the Number of the rows used
NumRows = ActiveSheet.UsedRange.Rows.Count
'Delete all rows ending with VARIABLE1 where value in Column 'VARIABLE2 is VARIABLE3
For iLine = NumRows To VARIABLE1 Step -1
If Range("VARIABLE2" & iLine).Value = "VARIABLE3" Then
Rows(iLine).EntireRow.Delete
End If
Next iLine
End Sub