|
-
Apr 24th, 2013, 08:43 AM
#1
Thread Starter
Fanatic Member
Delete rows in VBA?
Hi,
would it be possible to delete all rows in my worksheets where any field in column F has $, i dont want to delete rows where column F contain $ but only rows where the cell only has $.
hopefully that makes sense?
Last edited by frankwhite; Apr 24th, 2013 at 08:44 AM.
Reason: Edit, I'm using excel 2010.
Please mark threads as resolved once the problem has been solved.
I apprecaite all your help/advice given 
-
Apr 24th, 2013, 08:51 AM
#2
Thread Starter
Fanatic Member
Re: Delete rows in VBA?
The following coding has helped alot but i'm not sure how to have it running across all worksheets?
Code:
Sub test()
With ActiveSheet
.AutoFilterMode = False
With Range("f1", Range("f" & Rows.Count).End(xlUp))
.AutoFilter 1, "*$*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
Please mark threads as resolved once the problem has been solved.
I apprecaite all your help/advice given 
-
Apr 24th, 2013, 09:18 AM
#3
Re: Delete rows in VBA?
something like:
Code:
Sub delRows()
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Set wb = ActiveWorkbook 'or set to a specific workbook name
For i = 1 To wb.Sheets.Count
Set ws = wb.Sheets(i)
With ws
'do stuff
End With
Next i
End Sub
-
Apr 25th, 2013, 04:36 AM
#4
Thread Starter
Fanatic Member
Re: Delete rows in VBA?
hi
i have tried the following but it doesnt do anything?
Code:
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Set wb = ActiveWorkbook
For i = 1 To wb.Sheets.Count
Set ws = wb.Sheets(i)
.AutoFilterMode = False
With Range("f1", Range("f" & Rows.Count).End(xlUp))
.AutoFilter 1, "*$*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
Next i
Please mark threads as resolved once the problem has been solved.
I apprecaite all your help/advice given 
-
Apr 25th, 2013, 06:14 AM
#5
Thread Starter
Fanatic Member
Re: Delete rows in VBA?
I have the following coding in place
Code:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'code
Next ws
the problem I have is the coding does work and it removes the rows but it only works for the last worksheet and not all worksheets?
Please mark threads as resolved once the problem has been solved.
I apprecaite all your help/advice given 
-
Apr 25th, 2013, 06:59 AM
#6
Re: Delete rows in VBA?
Try this:
Code:
Sub delRows()
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Set wb = ActiveWorkbook 'or set to a specific workbook name
For i = 1 To wb.Sheets.Count
Set ws = wb.Sheets(i)
With ws
ws.Range("a1").EntireRow.Delete
MsgBox "deleted row 1 in sheet " & ws.Name
End With
Next i
End Sub
It should delete the first row in each worksheet of your active workbook.
-
Apr 26th, 2013, 09:31 AM
#7
New Member
Re: Delete rows in VBA?
i think your problem need change to follow this code:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
'code
Next ws
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
|