Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hello,
Currently I have data in the form: a ball b hat a cat c dog I want to show this using a macro/vba code: item1 item2 a ball cat b hat c dog Either excel or access would be fine, just can't figure out an automatic way to do this. Thanks, Tristan |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try using a pivot table.
On May 19, 8:45 am, Twisty1980 wrote: Hello, Currently I have data in the form: a ball b hat a cat c dog I want to show this using a macro/vba code: item1 item2 a ball cat b hat c dog Either excel or access would be fine, just can't figure out an automatic way to do this. Thanks, Tristan |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Have done won't work, pivot table doesn't know to assign item 1 etc to each
instance of a new item "Tim879" wrote: Try using a pivot table. On May 19, 8:45 am, Twisty1980 wrote: Hello, Currently I have data in the form: a ball b hat a cat c dog I want to show this using a macro/vba code: item1 item2 a ball cat b hat c dog Either excel or access would be fine, just can't figure out an automatic way to do this. Thanks, Tristan |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Assuming that the source data is in a sheet called "s1" and the destination
in a sheets called "s2": Sub reOrganize() ' ' gsnuxx ' Set s1 = Sheets("s1") Set s2 = Sheets("s2") s2.Range("A1").Value = s1.Range("A1").Value na = s1.Cells(Rows.Count, "A").End(xlUp).Row n2 = 2 For i = 2 To na v = s1.Cells(i, 1).Value Set r = s1.Range("A1:A" & i) If Application.WorksheetFunction.CountIf(r, v) = 1 Then s2.Cells(n2, 1).Value = v n2 = n2 + 1 End If Next For i = 1 To n2 - 1 j = 2 v = s2.Cells(i, 1).Value For k = 1 To na w = s1.Cells(k, 1).Value If v = w Then s2.Cells(i, j).Value = s1.Cells(k, 2).Value j = j + 1 End If Next Next End Sub -- Gary''s Student - gsnu200787 "Twisty1980" wrote: Hello, Currently I have data in the form: a ball b hat a cat c dog I want to show this using a macro/vba code: item1 item2 a ball cat b hat c dog Either excel or access would be fine, just can't figure out an automatic way to do this. Thanks, Tristan |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks very much,
last question if I wanted to put in a criteria to group when both columns a and b are the same. how should I go about modifying the code: eg first name second name item john G ball john c cat john G mouse result: first name second name item1 item2 john G ball cat Thanks again Tristan "Gary''s Student" wrote: Assuming that the source data is in a sheet called "s1" and the destination in a sheets called "s2": Sub reOrganize() ' ' gsnuxx ' Set s1 = Sheets("s1") Set s2 = Sheets("s2") s2.Range("A1").Value = s1.Range("A1").Value na = s1.Cells(Rows.Count, "A").End(xlUp).Row n2 = 2 For i = 2 To na v = s1.Cells(i, 1).Value Set r = s1.Range("A1:A" & i) If Application.WorksheetFunction.CountIf(r, v) = 1 Then s2.Cells(n2, 1).Value = v n2 = n2 + 1 End If Next For i = 1 To n2 - 1 j = 2 v = s2.Cells(i, 1).Value For k = 1 To na w = s1.Cells(k, 1).Value If v = w Then s2.Cells(i, j).Value = s1.Cells(k, 2).Value j = j + 1 End If Next Next End Sub -- Gary''s Student - gsnu200787 "Twisty1980" wrote: Hello, Currently I have data in the form: a ball b hat a cat c dog I want to show this using a macro/vba code: item1 item2 a ball cat b hat c dog Either excel or access would be fine, just can't figure out an automatic way to do this. Thanks, Tristan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formatting a table with subtotals | Excel Discussion (Misc queries) | |||
Conditional formatting in a table is lost on table refresh | Excel Worksheet Functions | |||
Pivot Table Formatting | Charts and Charting in Excel | |||
pivot table formatting | Excel Worksheet Functions | |||
Pivot Table border formatting and pivot chart formatting | Excel Discussion (Misc queries) |