ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting rows with variable (https://www.excelbanter.com/excel-programming/276902-selecting-rows-variable.html)

Jim[_24_]

Selecting rows with variable
 
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?

Trevor Shuttleworth

Selecting rows with variable
 
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?




Don Guillett[_4_]

Selecting rows with variable
 
try this

count_y=20
Rows("4:" & count_y ).entirerow.delete

"Jim" wrote in message
...
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?




Trevor Shuttleworth

Selecting rows with variable
 
Don

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

Regards

Trevor


"Don Guillett" wrote in message
...
Trevor,
You may have been faster but I deleted more rows. <G

"Trevor Shuttleworth" wrote in message
...
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?








Don Guillett[_4_]

Selecting rows with variable
 
Ah, OK.

"Trevor Shuttleworth" wrote in message
...
Don

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

Regards

Trevor


"Don Guillett" wrote in message
...
Trevor,
You may have been faster but I deleted more rows. <G

"Trevor Shuttleworth" wrote in message
...
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?









Arielle[_2_]

Selecting rows withTWO variables
 
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

"Don Guillett" wrote in message ...
Ah, OK.

"Trevor Shuttleworth" wrote in message
...
Don

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

Regards

Trevor


"Don Guillett" wrote in message
...
Trevor,
You may have been faster but I deleted more rows. <G

"Trevor Shuttleworth" wrote in message
...
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?







Trevor Shuttleworth

Selecting rows withTWO variables
 
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


"Arielle" wrote in message
om...
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

"Don Guillett" wrote in message

...
Ah, OK.

"Trevor Shuttleworth" wrote in message
...
Don

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

Regards

Trevor


"Don Guillett" wrote in message
...
Trevor,
You may have been faster but I deleted more rows. <G

"Trevor Shuttleworth" wrote in message
...
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?









Arielle[_2_]

Selecting rows withTWO variables
 
Thanks Trevor!

"Trevor Shuttleworth" wrote in message ...
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


"Arielle" wrote in message
om...
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

"Don Guillett" wrote in message

...
Ah, OK.

"Trevor Shuttleworth" wrote in message
...
Don

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

Regards

Trevor


"Don Guillett" wrote in message
...
Trevor,
You may have been faster but I deleted more rows. <G

"Trevor Shuttleworth" wrote in message
...
Jim

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

works for me

Regards

Trevor


"Jim" wrote in message
...
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?








All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com