Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Delete Unwanted Rows (Help with Range)

I've got the following function but unfortunately I'm not too sure how
to modify the range to go down to the bottom of the Spreadsheet then
delete rows, so I did it manually, because my journals are getting
larger and larger the range isn't good enough and I want to set it
automatically. Can someone assist me in how to get there?

---------------------------------------------------------------------------------------------------------------------------------------
Sub Delete_Unwanted_Rows_2()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual




Dim Rng As Range
Dim i As Integer, counter As Integer


'Set the range to evaluate to rng.
Set Rng = Range("B18:B1147")

'initialize i to 1
i = 1

'Loop for a count of 1 to the number of rows
'in the range that you want to evaluate.
For counter = 1 To Rng.Rows.Count

'If cell i in the range contains an "x",
'delete the row.
'Else increment i
If Rng.Cells(i) = "" Then
Rng.Cells(i).EntireRow.Delete
Else
i = i + 1
End If

Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
---------------------------------------------------------------------------------------------------------------------------------------


The last row which is the balance has an "O" in column B. I think the
..xldown should be used but I'm not too sure how to use it.
Thank you for your help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Unwanted Rows (Help with Range)

Hi Santa-D,

Try:

Dim iLrow As Long

iLrow = Cells(Rows.Count, "B").End(xlUp).Row
Set Rng = Range("B18:B" & iLrow)


---
Regards,
Norman



"Santa-D" wrote in message
oups.com...
I've got the following function but unfortunately I'm not too sure how
to modify the range to go down to the bottom of the Spreadsheet then
delete rows, so I did it manually, because my journals are getting
larger and larger the range isn't good enough and I want to set it
automatically. Can someone assist me in how to get there?

---------------------------------------------------------------------------------------------------------------------------------------
Sub Delete_Unwanted_Rows_2()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual




Dim Rng As Range
Dim i As Integer, counter As Integer


'Set the range to evaluate to rng.
Set Rng = Range("B18:B1147")

'initialize i to 1
i = 1

'Loop for a count of 1 to the number of rows
'in the range that you want to evaluate.
For counter = 1 To Rng.Rows.Count

'If cell i in the range contains an "x",
'delete the row.
'Else increment i
If Rng.Cells(i) = "" Then
Rng.Cells(i).EntireRow.Delete
Else
i = i + 1
End If

Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
---------------------------------------------------------------------------------------------------------------------------------------


The last row which is the balance has an "O" in column B. I think the
.xldown should be used but I'm not too sure how to use it.
Thank you for your help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select a range of rows to delete Donna[_3_] Excel Worksheet Functions 2 January 26th 10 07:32 PM
Delete a range of rows ? SpookiePower Excel Programming 6 January 24th 06 03:24 PM
Delete Rows & Capture Range sameer27p[_22_] Excel Programming 3 August 5th 04 05:43 AM
Delete all Rows in a Variable Range John[_78_] Excel Programming 3 June 30th 04 06:13 PM
Delete unwanted rows Ken Wright Excel Programming 1 August 11th 03 11:33 AM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"