PC Review


Reply
Thread Tools Rate Thread

Delete All Rows Above Trigger

 
 
CFitz
Guest
Posts: n/a
 
      8th Jul 2008
I'm looking for a macro that will find the row that contains the word "Other"
and then delete every row above it. Unfortunately there isn't a specific
column to look in because columns are constantly being added and subtracted
from the file.

Thanks!
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      8th Jul 2008
See if this works. I didn't test it.

Sub DelAllAbove()
Dim c As Range
Set c = ActiveWorkbook.ActiveSheet. _
Find("Other", LookIn:=xlValues)
If Not c Is Nothing Then
Range("A1:A" & c.Row + 1).EntireRow.Delete
End If
End Sub

"CFitz" wrote:

> I'm looking for a macro that will find the row that contains the word "Other"
> and then delete every row above it. Unfortunately there isn't a specific
> column to look in because columns are constantly being added and subtracted
> from the file.
>
> Thanks!

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      8th Jul 2008
I had a typo in the first one. Should have been a minus sign.

Sub DelAllAbove()
Dim c As Range
Set c = ActiveWorkbook.ActiveSheet. _
Find("Other", LookIn:=xlValues)
If Not c Is Nothing Then
Range("A1:A" & c.Row - 1).EntireRow.Delete
End If
End Sub

"CFitz" wrote:

> I'm looking for a macro that will find the row that contains the word "Other"
> and then delete every row above it. Unfortunately there isn't a specific
> column to look in because columns are constantly being added and subtracted
> from the file.
>
> Thanks!

 
Reply With Quote
 
CFitz
Guest
Posts: n/a
 
      8th Jul 2008
It didn't work. I'm getting an error that says "Object doesn't support this
property or method" and it highlights

Set c = ActiveSheet. _
Find("Other", LookIn:=xlValues)

"JLGWhiz" wrote:

> See if this works. I didn't test it.
>
> Sub DelAllAbove()
> Dim c As Range
> Set c = ActiveWorkbook.ActiveSheet. _
> Find("Other", LookIn:=xlValues)
> If Not c Is Nothing Then
> Range("A1:A" & c.Row + 1).EntireRow.Delete
> End If
> End Sub
>
> "CFitz" wrote:
>
> > I'm looking for a macro that will find the row that contains the word "Other"
> > and then delete every row above it. Unfortunately there isn't a specific
> > column to look in because columns are constantly being added and subtracted
> > from the file.
> >
> > Thanks!

 
Reply With Quote
 
CFitz
Guest
Posts: n/a
 
      8th Jul 2008
Still getting the same error as above.

"JLGWhiz" wrote:

> I had a typo in the first one. Should have been a minus sign.
>
> Sub DelAllAbove()
> Dim c As Range
> Set c = ActiveWorkbook.ActiveSheet. _
> Find("Other", LookIn:=xlValues)
> If Not c Is Nothing Then
> Range("A1:A" & c.Row - 1).EntireRow.Delete
> End If
> End Sub
>
> "CFitz" wrote:
>
> > I'm looking for a macro that will find the row that contains the word "Other"
> > and then delete every row above it. Unfortunately there isn't a specific
> > column to look in because columns are constantly being added and subtracted
> > from the file.
> >
> > Thanks!

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      8th Jul 2008
Sub DelAllAbove()
Dim c As Range
With ActiveSheet
Set c = .Cells _
.Find("Other", LookIn:=xlValues)
If Not c Is Nothing Then
If c.Row = 1 Then
.Rows(1).Delete
Else
.Range("A1:A" & c.Row - 1).EntireRow.Delete
End If
Else
MsgBox "Other not found"
End If
End With
End Sub

--
Regards,
Tom Ogilvy


"CFitz" wrote:

> It didn't work. I'm getting an error that says "Object doesn't support this
> property or method" and it highlights
>
> Set c = ActiveSheet. _
> Find("Other", LookIn:=xlValues)
>
> "JLGWhiz" wrote:
>
> > See if this works. I didn't test it.
> >
> > Sub DelAllAbove()
> > Dim c As Range
> > Set c = ActiveWorkbook.ActiveSheet. _
> > Find("Other", LookIn:=xlValues)
> > If Not c Is Nothing Then
> > Range("A1:A" & c.Row + 1).EntireRow.Delete
> > End If
> > End Sub
> >
> > "CFitz" wrote:
> >
> > > I'm looking for a macro that will find the row that contains the word "Other"
> > > and then delete every row above it. Unfortunately there isn't a specific
> > > column to look in because columns are constantly being added and subtracted
> > > from the file.
> > >
> > > Thanks!

 
Reply With Quote
 
CFitz
Guest
Posts: n/a
 
      8th Jul 2008
Thanks!

"Tom Ogilvy" wrote:

> Sub DelAllAbove()
> Dim c As Range
> With ActiveSheet
> Set c = .Cells _
> .Find("Other", LookIn:=xlValues)
> If Not c Is Nothing Then
> If c.Row = 1 Then
> .Rows(1).Delete
> Else
> .Range("A1:A" & c.Row - 1).EntireRow.Delete
> End If
> Else
> MsgBox "Other not found"
> End If
> End With
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> "CFitz" wrote:
>
> > It didn't work. I'm getting an error that says "Object doesn't support this
> > property or method" and it highlights
> >
> > Set c = ActiveSheet. _
> > Find("Other", LookIn:=xlValues)
> >
> > "JLGWhiz" wrote:
> >
> > > See if this works. I didn't test it.
> > >
> > > Sub DelAllAbove()
> > > Dim c As Range
> > > Set c = ActiveWorkbook.ActiveSheet. _
> > > Find("Other", LookIn:=xlValues)
> > > If Not c Is Nothing Then
> > > Range("A1:A" & c.Row + 1).EntireRow.Delete
> > > End If
> > > End Sub
> > >
> > > "CFitz" wrote:
> > >
> > > > I'm looking for a macro that will find the row that contains the word "Other"
> > > > and then delete every row above it. Unfortunately there isn't a specific
> > > > column to look in because columns are constantly being added and subtracted
> > > > from the file.
> > > >
> > > > Thanks!

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      8th Jul 2008
Yeah, haste makes waste. Forgot the Cells. Without that it don't know where
to look. Tom caught it right off.

"CFitz" wrote:

> Still getting the same error as above.
>
> "JLGWhiz" wrote:
>
> > I had a typo in the first one. Should have been a minus sign.
> >
> > Sub DelAllAbove()
> > Dim c As Range
> > Set c = ActiveWorkbook.ActiveSheet. _
> > Find("Other", LookIn:=xlValues)
> > If Not c Is Nothing Then
> > Range("A1:A" & c.Row - 1).EntireRow.Delete
> > End If
> > End Sub
> >
> > "CFitz" wrote:
> >
> > > I'm looking for a macro that will find the row that contains the word "Other"
> > > and then delete every row above it. Unfortunately there isn't a specific
> > > column to look in because columns are constantly being added and subtracted
> > > from the file.
> > >
> > > Thanks!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
INSTEAD OF TRIGGER to DELETE error AlwaysOnTime Microsoft Access ADP SQL Server 0 21st Oct 2008 05:55 PM
After delete Trigger on Transaction sandi@e-axioma.com Microsoft ADO .NET 0 12th Jun 2006 01:04 PM
Inserting rows on cell trigger AMK4 Microsoft Excel Programming 0 1st Feb 2006 08:44 PM
why can stored proc update multiple rows but trigger can't? Joss Microsoft Access 1 26th Apr 2005 09:59 PM
trigger delete event Geraldine Hobley@hotmail.com Microsoft Access Forms 0 9th Dec 2003 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:55 PM.