Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default macro for arranging by Contract #

Hello experts,

I am trying to arrange information by contract # or by date. I produce a
material everyday and input the information into the spreadsheet the latest
is the last line but the contract #'s vary per day (See example #1). I want
to organize everything either by contract # or by date so that I can graph
each accordingly (example #2). The graphing part is working either way I
put the data in to the sheet.

Example #1:
Date Cont # Gmm Gse #200
7/18 123 2.654 2.890 5.2
7/20 564 2.650 2.889 4.2
7/21 123 2.657 2.895 6.8

Example #2:
7/18 123 2.654 2.890 5.2
7/21 123 2.657 2.895 6.8
7/20 564 2.650 2.889 4.2

Any help would be appreciated. Thank you all in advance!!

Eric
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default macro for arranging by Contract #

Try something like this. This assumes that your headers are in row 1.

Sub Sort()

Dim aWS As Worksheet
Dim myRange As Range
Dim lRow As Long
Set aWS = ActiveSheet
Set myRange = aWS.Range("A1")
lRow = aWS.Cells(aWS.Rows.Count, myRange.Column).End(xlUp).Row

Set myRange = myRange.Resize(lRow - myRange.Row + 1, 5) '<~~~can change the
# of columns here
myRange.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

--
HTH,
Barb Reinhardt



"Eric" wrote:

Hello experts,

I am trying to arrange information by contract # or by date. I produce a
material everyday and input the information into the spreadsheet the latest
is the last line but the contract #'s vary per day (See example #1). I want
to organize everything either by contract # or by date so that I can graph
each accordingly (example #2). The graphing part is working either way I
put the data in to the sheet.

Example #1:
Date Cont # Gmm Gse #200
7/18 123 2.654 2.890 5.2
7/20 564 2.650 2.889 4.2
7/21 123 2.657 2.895 6.8

Example #2:
7/18 123 2.654 2.890 5.2
7/21 123 2.657 2.895 6.8
7/20 564 2.650 2.889 4.2

Any help would be appreciated. Thank you all in advance!!

Eric

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default macro for arranging by Contract #

The headers are not in row 1 they are in row 26. I am assuming that this
would change the macro at this point; Set myRange = aWS.Range("A1") change
("A1") to ("A26"). Correct?


Eric

"Barb Reinhardt" wrote:

Try something like this. This assumes that your headers are in row 1.

Sub Sort()

Dim aWS As Worksheet
Dim myRange As Range
Dim lRow As Long
Set aWS = ActiveSheet
Set myRange = aWS.Range("A1")
lRow = aWS.Cells(aWS.Rows.Count, myRange.Column).End(xlUp).Row

Set myRange = myRange.Resize(lRow - myRange.Row + 1, 5) '<~~~can change the
# of columns here
myRange.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

--
HTH,
Barb Reinhardt



"Eric" wrote:

Hello experts,

I am trying to arrange information by contract # or by date. I produce a
material everyday and input the information into the spreadsheet the latest
is the last line but the contract #'s vary per day (See example #1). I want
to organize everything either by contract # or by date so that I can graph
each accordingly (example #2). The graphing part is working either way I
put the data in to the sheet.

Example #1:
Date Cont # Gmm Gse #200
7/18 123 2.654 2.890 5.2
7/20 564 2.650 2.889 4.2
7/21 123 2.657 2.895 6.8

Example #2:
7/18 123 2.654 2.890 5.2
7/21 123 2.657 2.895 6.8
7/20 564 2.650 2.889 4.2

Any help would be appreciated. Thank you all in advance!!

Eric

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default macro for arranging by Contract #

Barb,

This command works great with 2 exceptions.

1. What if I want to have a certain contract that I want on top
ie:456 instead of 123. With the macro you gave me it does the contracts in
numerical order.

2. If I have to count the columns backwards how do I do this? Putting in a
negative sign isn't working nor is placing brackets around it.

IE:
Set myRange = aWS.Range("H1")
lRow = aWS.Cells(aWS.Rows.Count, myRange.Column).End(xlUp).Row

Set myRange = myRange.Resize(lRow - myRange.Row + 1,- 5)

I again appreciate all the help. Have a great weekend.

Eric


"Barb Reinhardt" wrote:

Try something like this. This assumes that your headers are in row 1.

Sub Sort()

Dim aWS As Worksheet
Dim myRange As Range
Dim lRow As Long
Set aWS = ActiveSheet
Set myRange = aWS.Range("A1")
lRow = aWS.Cells(aWS.Rows.Count, myRange.Column).End(xlUp).Row

Set myRange = myRange.Resize(lRow - myRange.Row + 1, 5) '<~~~can change the
# of columns here
myRange.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

--
HTH,
Barb Reinhardt



"Eric" wrote:

Hello experts,

I am trying to arrange information by contract # or by date. I produce a
material everyday and input the information into the spreadsheet the latest
is the last line but the contract #'s vary per day (See example #1). I want
to organize everything either by contract # or by date so that I can graph
each accordingly (example #2). The graphing part is working either way I
put the data in to the sheet.

Example #1:
Date Cont # Gmm Gse #200
7/18 123 2.654 2.890 5.2
7/20 564 2.650 2.889 4.2
7/21 123 2.657 2.895 6.8

Example #2:
7/18 123 2.654 2.890 5.2
7/21 123 2.657 2.895 6.8
7/20 564 2.650 2.889 4.2

Any help would be appreciated. Thank you all in advance!!

Eric

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
Using contract start/end dates and calculating annual contract day Redcon Excel Discussion (Misc queries) 3 April 19th 08 12:03 AM
Contract VBA Programmer KC VBA Qns Excel Programming 1 September 8th 07 07:52 AM
need a macro for arranging the data yagna Excel Programming 3 April 1st 06 01:56 PM
macro for shifting/combining and arranging data Daniel M[_2_] Excel Programming 1 June 4th 04 01:49 PM
macro for shifting/combining and arranging data Daniel M[_2_] Excel Programming 3 June 2nd 04 04:10 AM


All times are GMT +1. The time now is 06:54 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"