macro: sort list, then print w/out blank rows

Hi,

i have been trying to write a macro (see below) that can do th
following:

1. Sort a list based on two columns.
2. Print the list including header row.

I have encountered the following problems: 

1. The first column by which I sort is sorted in Ascending order. I a
sorting a selected range (see below). This resulted in those rows i
that range that were left blank to come up first. I want to ignor
those rows.

2. When I let the macro print the range, it prints the whole range
What do I do to have only those rows printed that are non-blank?

Range("A6:F10005").Select
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending
Key2:=Range("E6") _
, Order2:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNormal


Any help appreciated! 
a

--
Message posted from http://www.ExcelForum.com

0
8/26/2004 2:04:40 AM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
732 Views

Similar Articles

[PageSpeed] 46

Hi
You could hide the rows that don't have data in column A using the
autofilter and print the visible range:
--
Range("A6:F10005").Sort _
          Key1:=Range("A6"), Order1:=xlAscending, _
          Key2:=Range("E6"), Order2:=xlDescending, _
          Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
          Orientation:=xlTopToBottom
  With Range("A6")
    .AutoFilter
    .AutoFilter Field:=1, Criteria1:="<>"
    .CurrentRegion.PrintOut
    .AutoFilter
  End With
--

Lydya

----------
"as_sass >" <<as_sass.1bkphs@excelforum-nospam.com> a �crit dans le message
de news:as_sass.1bkphs@excelforum-nospam.com...
> Hi,
>
> i have been trying to write a macro (see below) that can do the
> following:
>
> 1. Sort a list based on two columns.
> 2. Print the list including header row.
>
> I have encountered the following problems:
>
> 1. The first column by which I sort is sorted in Ascending order. I am
> sorting a selected range (see below). This resulted in those rows in
> that range that were left blank to come up first. I want to ignore
> those rows.
>
> 2. When I let the macro print the range, it prints the whole range.
> What do I do to have only those rows printed that are non-blank?
>
> Range("A6:F10005").Select
> Selection.Sort Key1:=Range("A6"), Order1:=xlAscending,
> Key2:=Range("E6") _
> , Order2:=xlDescending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
> _
> DataOption1:=xlSortNormal
>
>
> Any help appreciated!
> as
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
8/26/2004 11:50:30 AM
Reply:

Similar Artilces:

deleting rows #4
In microsoft encell 2000 when i delete a row (say row 5) the row disapears but so does the row number then all other rows are moved up is there a way to delete the row and keep the number 5? The row number shouldn't disappear unless you are hiding the row, not deleting it -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Doctorpc631" <doctorpc631@aol.com> wrote in message news:e4FaNYV4EHA.1260@TK2MSFTNGP12.phx.gbl... > In microsoft encell 2000 when i delete a row (say row 5) the row > disapears > but s...

List Control
I want to add list control header like "First Column", "Second Column", I would like it is showed as 2 lines header by "First \nColumn", "Second \nColumn", But it does not work. How to do that? ...

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

Another address list ?
Hi - I am running Exchange 2003 on Win2003 SBS edition. Could someone tell me whether it is possible to have another address list which exists separate to the GAL ? So for example if you compose a new message and click on the To button, I would like the users to see the GAL and also another entry underneath saying "External Emails" which will have the external user email addresses in it" How do you go about doing this ? Thanks in advance You would create this in the Address Lists container in Exchange System Manager. "Edward" <dont-mail@me.com> wrote...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Database is not listed in ODBC to default
Hi! I am trying to create a ODBC and default the Database in order for this ODBC to use in Crysral Reports, but I could see all Databases except the one I am looking for. I am using Windows Authentication and Namedpipes in the settings and necessary access has been given in SQL for this Windows user. I've tried even creating a new ODBC, it doesn't show the database that I'm looking for. Does any one experienced this before? Regards, Venkata N M Punugu If you are using Windows authentication, make sure the Windows user is added to the database. -- Charles Allen, MVP ...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Terminal Server based Outlook 2007 printing hieroglyphics
We are running terminal services(Server 2008 R2) with Outlook 2007 installed (SP2). No other Office components are installed. When printing emails, (all other printing is fine), the text becomes compressed and looks like hieroglyphics. 1. I have tried removing all printer drivers and re-installing the drivers with no luck. 2. I have also applied the lastest patches and Service packs to the server and Outlook. 3. I have tried using different types of drivers with each printer ie. PS, MS, PCL5e, PCL6 etc with no luck. Any help would be appreciated as users are getting very fr...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Changing Rows to Columns
Is it possible to easily rotate a spreadsheet or part of a spreadshet, to change the data in rows to columns? Do to a sorting problem in the charts I create, it seems I have to sort the data in the spreadsheet first. Any help would be appreciated. Hi, Sure is a way. select & copy your data. then select the cell where you want to re-paste; right-click and select paste special; in the dialog box check "transpose". Ok. jeff >-----Original Message----- >Is it possible to easily rotate a spreadsheet or part of a >spreadshet, to change the data in rows to columns? D...

Sum after Sorting #2
There is an Excel Spreadsheet like the following Project Value Sum Power 120 354 (Power + Computer) Computer 234 AV 123 Quest 200 In other words, the formula for 354 is "=B2+B3" There is a requirement that we have to sort the first column in ascending order but keep the sum still be the value for Power & Computer (as follow) Project Value Sum AV 123 354 Computer 234 Power 120 Quest 200 I have tried a number of ways but still cannot get it fixed. Is there any suggestion ? Hi! Based on your example in the second table it lo...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

Printing checks without printing EFT's
We pay vendors using mostly EFT's but still pay some via check. First we run EFT's and then run checks separately. However sometimes the check batch also includes EFT's thus we need a method to select checks only. Question is how can I select only the check vendors for payment. When paying via EFT, there is a selection for "EFT Only" but no such selection for "Checks Only". Is there a way around this issue? Doug Hi Doug I was browsing and saw this, we had a similar scenario We solved it by using payment priority within the creditor (under options) ...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

Lists
Okay I am new to excell bar drawing little spreadsheets to do my own financing. I am currently setting up a sheet and need the users to be able to select from a list of options only and not input thier own text - does that make sense? also i ahve 12 names on the list and one master with all on - would like the data entered on to a names list to be automatically entered onto the master or vice versa which ever is easiest. sorry if this sounds jumbled but i am totally lost and this has to look really hot for work! regards Kelly - England Hi Kerry, don't know a great deal on forms ...

Banding when printing Gradients in Excel 2007
I use complex spreadsheets with macros to report company sales data. The reports were created in Excel 2002. When I print the charts from 2002, they print fine... text is crisp and gradients are gradients. When I print the same charts in Excel 2007, the gradients don't print. Rather I get a series of four distinct color bands. The lines and text are also not crisp but rather jagged. We use a color "powerhouse" laser printer -- Gestener aka Ricoh (too many copies to print on an inkjet). Has anyone had this problem? Anyone know of a fix? ...

RE: last post about listing e-mail address rather than name.......
That is in Outlook Express 6.0. BTW, is there a separate newsgroup for Outlook Express...I couldn't find one?!!!!! ...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

How do I get my publisher 2003 documents to print to the edge of .
How can I get documents to print to the edge of a page in Publisher 2003? I want my picture to bleed to the edge and have set all gaps to 0. Yet I still get a big white border around each side of the page as opposed to the graphics printing to the edge. Ple Is your printer capable of doing that? Not all are. -- JoAnn Paules MVP Microsoft [Publisher] "Macey" <Macey@discussions.microsoft.com> wrote in message news:C4FA27CF-D2F2-47E7-B35D-D100ABF3B70A@microsoft.com... > How can I get documents to print to the edge of a page in Publisher 2003? > I > want my pi...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

Turn off auto adjust of row heights
I have a complex spreadsheet for my catalogue of products. I have set row heights, fonts and sizes of texts for different rows. Every now and then my row heights are automatically changed by EXCEL. I have turned off word wrap I have locked/protected my sheet. How can I stop EXCEL automatically readjusting row heights at its discretion. Thanks ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

How do you print the membership of a distribution group in E2k3
How do you print the membership of a distribution group in E2k3 In 5.5, there was the awkward workaround to "add (or remove) a member, then highlight all the users from their and copy them to the clipboard and paste them in a text file. Don't see "export contents" - You can but it's blank. Don't see any way to get to a copyable list. What am I missing? believe it or not, the easiest way is via Outlook... Create a new meeting request...select the group to invite. Then "expand" the group in the attendee availability window. Then select all of the membe...