Selecting rows with variable

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Im trying to select, then delete a whole lod of rows in
one go. Im trying to use the following commands:
Rows("4:" & count_y ).Select
Selection.Delete Shift:=xlUp

It doesn't like this at all. How can I get it to do what
I want?
 
Jim

Sub TestDeleteRows()
Dim RowCounter As Long
RowCounter = 10
Rows("4:" & RowCounter).EntireRow.Delete
End Sub

works for me

Regards

Trevor
 
Don

it's not the winning that counts, it's the taking part ;-)

Regards

Trevor
 
I cannot get this to work for 2 variables - please advise: (goal is to
get user input, perform calculations on input and use those row
numbers as rows to delete from:to)

Sub RowDel()
Dim UserSpace As Integer
Do Until UserNum <> ""
UserNum = InputBox("Enter Trip Number to Delete:", "Delete Trip")
Loop
UserSpace = InStr(UserNum, "test")
If UserSpace <> 0 Then
UserNum = Left(UserNum, UserSpace - 1)
End If
Dim BegNum As Long
Dim EndNum As Long
EndNum = UserNum * 24 + 1
BegNum = EndNum - 23
Rows(& BegNum:& EndNum).EntireRow.Delete Shift:=xlUp

End Sub
 
Arielle

you would be better off starting a new thread. However, I assume it is just
the last line that is a problem.

Try:

Rows(BegNum & ":" & EndNum).EntireRow.Delete

Regards

Trevor
 
Thanks Trevor!

Trevor Shuttleworth said:
Arielle

you would be better off starting a new thread. However, I assume it is just
the last line that is a problem.

Try:

Rows(BegNum & ":" & EndNum).EntireRow.Delete

Regards

Trevor
 
Back
Top