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

Workbook contains multiple sheets with papers published by various authors.
Each sheet contains papers of a different status, e.g., in press, published,
with multiple authors listed on each worksheet.
I have created the following macro to pull records from multiple sheets for
a single author. I had to set the ranges at 50 lines apart because various
authors have different numbers of records. Now I'd like to delete empty
rows.
I'm sure there is a simple addition to the macro that would delete empty rows.
Can anyone help?
Thanks,
K

Sub AllWork()
'
' AllWork Macro
' Macro recorded 9/27/2004 by Kristin Kraus
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Sheets("Published-2003").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A1:A2"), CopyToRange:=Range("A5"), Unique:=False
Sheets("Published-2004").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A1:A2"), CopyToRange:=Range("A50"),
Unique:=False
Sheets("In Press").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A100"), Unique:=False
Sheets("Submitted").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A150"), Unique:=False
Sheets("In Prep").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A200"), Unique:=False
Sheets("OtherDocs").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A250"), Unique:=False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Macro programming

Hi Kristin,

You can determine programmatically the last non-empty cell in A:A and copy
the data on the row bellow, instead of copying every 50 rows.

The expression:
Range("A65536").End(XlUp)
returns the last none empty cell in cpolumn A. It is similar to going to
cell A65536 and pressing CTRL+UpArrow. That is:
Range("A65536").End(XlUp).Offset(1,0)
returns the following cell which is empty. This is where you want to copy
your new set of data at each CopyToRange.

Now, assuming you have headers in row 4, replace all
CopyToRange:=Range("A5")
CopyToRange:=Range("A50")
CopyToRange:=Range("A100")
...
By
Range("A65536").End(XlUp).Offset(1,0)

Regards,
Sebastien

"Kristin" wrote:

Workbook contains multiple sheets with papers published by various authors.
Each sheet contains papers of a different status, e.g., in press, published,
with multiple authors listed on each worksheet.
I have created the following macro to pull records from multiple sheets for
a single author. I had to set the ranges at 50 lines apart because various
authors have different numbers of records. Now I'd like to delete empty
rows.
I'm sure there is a simple addition to the macro that would delete empty rows.
Can anyone help?
Thanks,
K

Sub AllWork()
'
' AllWork Macro
' Macro recorded 9/27/2004 by Kristin Kraus
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Sheets("Published-2003").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A1:A2"), CopyToRange:=Range("A5"), Unique:=False
Sheets("Published-2004").Cells.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A1:A2"), CopyToRange:=Range("A50"),
Unique:=False
Sheets("In Press").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A100"), Unique:=False
Sheets("Submitted").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A150"), Unique:=False
Sheets("In Prep").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A200"), Unique:=False
Sheets("OtherDocs").Cells.AdvancedFilter Action:=xlFilterCopy,
CriteriaRange _
:=Range("A1:A2"), CopyToRange:=Range("A250"), Unique:=False
End Sub

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 Programming Question mtbcpa Excel Discussion (Misc queries) 2 November 26th 07 04:51 PM
Excel Macro programming Kass[_2_] Excel Programming 2 January 28th 04 03:04 AM
loopig in Macro Programming Rasoul Khoshravan Azar Excel Programming 4 January 4th 04 02:00 PM
macro programming problem Dave Murto[_2_] Excel Programming 1 January 3rd 04 02:29 AM
Macro Programming Jamie[_3_] Excel Programming 1 August 27th 03 08:20 PM


All times are GMT +1. The time now is 01:48 AM.

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"