If desired, send me your file dguillett1 @gmail.com with code and complete
explanation.
Don Guillett
SalesAid Software
dguille...@gmail.com
-----Original Message-----
From: christoph404
Sent: Saturday, January 07, 2012 9:10 AM
To: MS EXCEL AND VBA MACROS
Subject: Re: $$Excel-Macros$$ Sorted Stacks in VBA
Hey Don,
Your answer is very much appreciated. However, as I stated at the end
of my post, I'm trying to avoids doing this action in the spreadsheet
but instead keep it in the code completely. Still, thanks!
Christoph
On Jan 7, 8:45 am, "dguillett1" <dguille...@gmail.com> wrote:
One way is to just have a macro create a helper column>sort by that>delete
the helper column. Here is one I did for someone that you can modify to
suit.
Option Explicit
Sub MakeReportSAS()
Dim lr As Long
Application.ScreenUpdating = False
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("P2:p" & lr).Formula = "=day(L2)"
'change formula to left (find the ,)
Range("a1:P" & lr).Sort Key1:=Range("P2"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Range("C:J,m:m").EntireColumn.Hidden = True
Columns("P").ClearContents
'Range("P1") = "Remarks"
'Range("p1:p" & lr).Borders.LineStyle = xlContinuous
'Columns("K:L").AutoFit
'Columns("P").ColumnWidth = 20
'Columns("O:O").HorizontalAlignment = xlCenter
'Range("N2:N" & lr).Style = "Currency"
Application.ScreenUpdating = True
End Sub
Don Guillett
SalesAid Software
dguille...@gmail.com
-----Original Message-----
From: christoph404
Sent: Friday, January 06, 2012 10:23 AM
To: MS EXCEL AND VBA MACROS
Subject: $$Excel-Macros$$ Sorted Stacks in VBA
Hi, I'm using Excel 2010 and am darn close to finishing a pretty cool
spreadsheet I built with the exception of one problem I can't seem to
solve. I a VBAS sub() that takes n pairs of two variables (n is
usually < 50). The pairs are always made up of one integer and one
string. For example, a pair could be 34, Peter. I want to push these
pairs onto a "stack" and once all of them are on there, sort them by
the integer number and then remove them from the "stack" in order. I
can't use an indexed array (if that even exists in VBA) because the
integer numbers don't have to be unique. What can I use? Collections?
How would that work with the sort?
Here's an example, these are elements I want to push onto th stack:
3437, Chris
3, Peter
98, Mike
82, Mary
98, Kate (note, same iteger as for Mike)
Then I want to sort the items by the integer and pop them off the
stack like this:
3, Peter
82, Mary
98, Mike (could be Kate, doesn't matter in which order)
98, Kate (could be Mike, doesn't matter in which order)
3437, Chris
Granted, a simple solution would just be to put the values into two
columns in an Excel spreadsheet and then sort by the integer. I'm
trying to avoid this though and make this a bit cleaner.
Any help is greatly appreciated.
Thanks,
Christoph
--
FORUM RULES (986+ members already BANNED for violation)
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
will
not get quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security
measure.
4) Acknowledge the responses you receive, good or bad.
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited.
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com
--
FORUM RULES (986+ members already BANNED for violation)
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security
measure.
4) Acknowledge the responses you receive, good or bad.
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited.
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com
--
FORUM RULES (986+ members already BANNED for violation)
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited.
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com