#1   Report Post  
 
Posts: n/a
Default Arrays

I have a set of values on one work sheet. On the second worksheet i
have a number of the same values with dates next to them. I need to
have the values from the first worksheet outputed horixontally on the
second worksheet.

That is:

worksheet one

abs 1/1/10
abs 1/1/11
abb 1/14/05
ab3 1/16/05
ab3 1/17/17
try 1/1/04

worksheet two

abs
abb
ab3

what i need
A B C
abs 1/1/10 1/1/11
abb 1/14/05
ab3 1/16/05 1/17/17

There are a lot of values (4000 on sheet 1 with 267 jobs (abs etc.) on
sheet 2). any help would be greatly appreciated.

thanks,
sam

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Your data is already sorted????

If yes, how about a little macro:

Option Explicit
Sub testme()
Dim curWks As Worksheet
Dim newWks As Worksheet
Dim iRow As Long
Dim oRow As Long
Dim oCol As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim PrevKey As Variant

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

PrevKey = ""
With curWks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

oRow = 0
oCol = 1
For iRow = FirstRow To LastRow
If .Cells(iRow, 1).Value = PrevKey Then
'keep adding to the right
newWks.Cells(oRow, oCol).Value = .Cells(iRow, 2).Value
oCol = oCol + 1
Else
'new key, go to next row
PrevKey = .Cells(iRow, 1).Value
oRow = oRow + 1
newWks.Cells(oRow, 1).Value = .Cells(iRow, 1).Value
newWks.Cells(oRow, 2).Value = .Cells(iRow, 2).Value
oCol = 3
End If
Next iRow
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

wrote:

I have a set of values on one work sheet. On the second worksheet i
have a number of the same values with dates next to them. I need to
have the values from the first worksheet outputed horixontally on the
second worksheet.

That is:

worksheet one

abs 1/1/10
abs 1/1/11
abb 1/14/05
ab3 1/16/05
ab3 1/17/17
try 1/1/04

worksheet two

abs
abb
ab3

what i need
A B C
abs 1/1/10 1/1/11
abb 1/14/05
ab3 1/16/05 1/17/17

There are a lot of values (4000 on sheet 1 with 267 jobs (abs etc.) on
sheet 2). any help would be greatly appreciated.

thanks,
sam


--

Dave Peterson
  #3   Report Post  
 
Posts: n/a
Default

Thank you, that worked well. And now, when i get a chance, i can figure
out why...

thanks again,

Sam

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
Formula Arrays VERY SLOW in Excel 2002 Patrick Excel Worksheet Functions 2 January 27th 05 12:59 AM
Employing constant arrays to limit nested IF statements. Richard-44 Excel Worksheet Functions 2 January 6th 05 02:19 AM
Updating Automatic links doesn't work with arrays Mats Samson Excel Discussion (Misc queries) 0 December 18th 04 03:17 PM
Comparing Arrays KL Excel Worksheet Functions 9 December 3rd 04 08:58 PM
Counting in arrays stumped Excel Worksheet Functions 5 November 12th 04 05:20 PM


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