LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Delete rows of data in multiple sheets

The TargetCol was not defined. See modified version.

Sub DeleteData_New()
Dim fRow As Long
Dim Sh As Worksheet
For Each Sh In Test.Sheets
With Sh
'If ActiveSheet.Name < sh.Name Then
'Sheets(sh.Name).Select
'End If
Set f = .Cells.Find(What:="Title for Month")
fRow = f.Row
LastRowToDelete = .Cells(fRow, 1).End(xlDown).Row
.Range(.Rows(fRow + 1), .Rows(LastRowToDelete)).Delete
End With
Next
End Sub


"Yossy" wrote:

This is exactly how I use it and I get this error. "Method or data member not
found" and it highlights the ".column". Also I declared a dim statement for
sh as I got error on that too.

Sub DeleteData_New()
Dim fRow As Long
Dim Sh As Sheets
For Each Sh In Test.Sheets
With Sh
'If ActiveSheet.Name < sh.Name Then
'Sheets(sh.Name).Select
'End If
Set f = .Columns(TargetCol).Find(What:="Title for Month")
MsgBox f.Row
fRow = f.Row
LastRowToDelete = .Cells(fRow, TargetCol).End(xlDown).Row
.Range(.Rows(fRow + 1), .Rows(LastRowToDelete)).Delete
End With
Next
End Sub

All hellp totally appeciated. Thanks a big bunch!!

"JLGWhiz" wrote:

Let's try this again, I put the wrong code in the previous post. This is the
one that I would use.

Sub DeleteData()
Dim fRow As Long
For Each Sh In ThisWorkbook.Sheets
With Sh
'If ActiveSheet.Name < sh.Name Then
'Sheets(sh.Name).Select
'End If
Set f = .Cells.Find(What:="Title for Month")
fRow = f.Row
LastRowToDelete = .Cells(fRow, 1).End(xlDown).Row
.Range(.Rows(fRow + 1), .Rows(LastRowToDelete)).Delete
End With
Next
End Sub

"Yossy" wrote:

I still get th same error. Please what am i missing. Helppppp me. Thanks

"JLGWhiz" wrote:

You are getting the error message on fRow = f.Row because you did not Dim fRow.

Add at the top of your code: Dim fRow As Long

"Yossy" wrote:

Anyone know why I am getting this error - "Object Variable or with block
variable not set" Please help... I want to delete rows of data below "Title
of Month" in multiple sheets. Thus where there is "Title of Month in all
sheets, the code should look below the title and delete the data only in the
row beneath the title until the last data. In this case my data are in Column
A.

Sub DeleteData()
TargetCol = "A"
For Each sh In ThisWorkbook.Sheets
If ActiveSheet.Name < sh.Name Then
Sheets(sh.Name).Select
End If
Set f = Columns(TargetCol).Find(What:="Title for Month")
fRow = f.Row
LastRowToDelete = Cells(fRow, TargetCol).End(xlDown).Row
Range(Rows(fRow + 1), Rows(LastRowToDelete)).Delete
Next
End Sub


Thanks a big bunch



 
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Proper procedures to delete multiple columns with 47,000 rows of data [email protected] Excel Discussion (Misc queries) 0 June 19th 08 06:01 PM
How to merge multiple rows of data to new formated sheets KJM Excel Discussion (Misc queries) 0 February 14th 07 08:13 PM
Delete rows in multiple sheets without loop? MTT727 Excel Programming 2 July 26th 05 03:07 PM
Delete Rows from multiple Sheets. drbobsled Excel Programming 3 April 7th 05 01:23 AM


All times are GMT +1. The time now is 08:23 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"