|
-
Aug 24th, 2004, 07:54 AM
#1
Thread Starter
New Member
Deleting rows in Excel
Hi
I'm trying to delete rows in excel which meet certain criteria without much success.
I have a spreadsheet with 13 columns and column F is an indicator which contains either "mortgage" or blank.
I need to delete all the rows in the spreadsheet that contain nothing in column F. The data will be refreshed on a daily basis so will have a varying number of rows.
I'm trying to create a macro in Excel 97, that when run, will delete all the rows but my VB knowledge is very limited.
Any help will be much appreciated.
Thanks
-
Aug 24th, 2004, 09:41 AM
#2
VB Code:
Do until lngLoop>100
if len(cells(lngLoop,6))=0 then
cells(lngloop,1).entirerow.delete
else
lngloop=lngloop+1
end if
loop
next
Something like that. Experiment.
Please note that this should work in vba (excel), it also does need to be assigned to the right objects which you will need to set up before calling.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 25th, 2004, 03:39 AM
#3
Thread Starter
New Member
Hi
Thank you for your reply.
I had a look on the internet before I received your reply and found the following code:-
Sub delnonmort2()
With ActiveSheet.UsedRange
lRow = Range(Cells(.Row, 1), Cells(.Rows.Count, 1)).Row
End With
Range("A1:M" & lRow).AutoFilter Field:=6, Criteria1:=""
Rows("2:" & lRow).Delete Shift:=xlUp
Selection.AutoFilter Field:=6
Selection.AutoFilter
End Sub
I've tried running it but I get a run time error 1004 saying "Microsoft Excel cannot insert or delete a column in a list while the Autofilter command is turned on."
This is the code debug highlights:-
"Rows("2:" & lRow).Delete Shift:=xlUp"
Any help please?
Thanks
Jules
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|