Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to delete first and last row

I need to delete the first and last row of a file everytime before
continuing on with the macro. Can anyone provide any tips? The first
line will always contain the same text, but the last line will vary
since the file is an export and the exported date/time is always
appended (i.e. 'Exported on 12/21/2006 3:05pm).

I found this code on the net to delete a line, but I modified it to try
and get it to use multiple conditions to delete:


Sub OpDivTickets()

Workbooks.Open Filename:= _
"C:\Documents and Settings\me\My Documents\Projects &
Proposals\ABC\Ticket Prioritization Meetings\Request Search
Results.xls"

Dim rng As Range
Dim what As String
what = "Request Search Results"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If


Dim rng As Range
Dim what As String
what like "Exported on"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop

Any help is appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Macro to delete first and last row

Just cleaning up the code you have...

Sub OpDivTickets()
Dim rng As Range
Dim what As String

Workbooks.Open Filename:= _
"C:\Documents and Settings\me\My Documents\Projects" & _
"Proposals\ABC\Ticket Prioritization Meetings\Request Search Results.xls"
' Sheets("You Name It").Activate

what = "Request Search Results"
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Else
rng.EntireRow.Delete
End If

what = "Exported on"
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Else
rng.EntireRow.Delete
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


wrote in message oups.com...
I need to delete the first and last row of a file everytime before
continuing on with the macro. Can anyone provide any tips? The first
line will always contain the same text, but the last line will vary
since the file is an export and the exported date/time is always
appended (i.e. 'Exported on 12/21/2006 3:05pm).

I found this code on the net to delete a line, but I modified it to try
and get it to use multiple conditions to delete:


Sub OpDivTickets()

Workbooks.Open Filename:= _
"C:\Documents and Settings\me\My Documents\Projects &
Proposals\ABC\Ticket Prioritization Meetings\Request Search
Results.xls"

Dim rng As Range
Dim what As String
what = "Request Search Results"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If


Dim rng As Range
Dim what As String
what like "Exported on"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop

Any help is appreciated

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
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM


All times are GMT +1. The time now is 10:42 PM.

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

About Us

"It's about Microsoft Excel"