Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Grouping Rows

Here is my situation:

I have a list of entries that i need to group according to their choice

so i get a list of people

Justin "choice1"
Sharon "choice2"
Marisa "choice3"
Joe "choice2"
John "choice3"
etc...

I have another sheet set up like this

choice1
choice2
choice3
choice4
....

i need to copy the cells from sheet 1 to sheet to so it ends up like
this
choice1
Justin
choice2
Sharon
Joe
choice3
Marisa
John
choice4
....
5
....

Can anyone help in this. I can post code but there is more to my
current code than what i am asking for here...i just need a place to
start.

Thanks,

Justin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Grouping Rows

Hi,
This assumes name in Col A, choice in column B:

Sub matchup()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, r As Long
Dim row As Variant

Set ws1 = Worksheets("sheet1") ' <=== change sheet names as required
Set ws2 = Worksheets("sheet2")
With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lastrow '<=== assumes data starts in row 2
Row = Application.Match(.Cells(r, "B"), ws2.Range("A:A"), 0)
If Not IsError(Row) Then
ws2.Cells(Row, "A").Offset(1, 0).EntireRow.Insert
ws2.Cells(Row + 1, "A") = .Cells(r, "A")
End If
Next r
End With


HTH

"Justin Philips" wrote:

Here is my situation:

I have a list of entries that i need to group according to their choice

so i get a list of people

Justin "choice1"
Sharon "choice2"
Marisa "choice3"
Joe "choice2"
John "choice3"
etc...

I have another sheet set up like this

choice1
choice2
choice3
choice4
....

i need to copy the cells from sheet 1 to sheet to so it ends up like
this
choice1
Justin
choice2
Sharon
Joe
choice3
Marisa
John
choice4
....
5
....

Can anyone help in this. I can post code but there is more to my
current code than what i am asking for here...i just need a place to
start.

Thanks,

Justin


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Grouping Rows

How would i make it so that entire row from sheet1 is inserted instead
of just the one cell?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Grouping Rows



If Not IsError(Row) Then
ws2.Cells(Row, "A").Offset(1, 0).EntireRow.Insert
.Cells(r, "A").EntireRow.Copy ws2.Cells(Row + 1, "A") '<===
amended code
End If

"Toppers" wrote:

Hi,
This assumes name in Col A, choice in column B:

Sub matchup()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, r As Long
Dim row As Variant

Set ws1 = Worksheets("sheet1") ' <=== change sheet names as required
Set ws2 = Worksheets("sheet2")
With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lastrow '<=== assumes data starts in row 2
Row = Application.Match(.Cells(r, "B"), ws2.Range("A:A"), 0)
If Not IsError(Row) Then
ws2.Cells(Row, "A").Offset(1, 0).EntireRow.Insert
ws2.Cells(Row + 1, "A") = .Cells(r, "A")
End If
Next r
End With


HTH

"Justin Philips" wrote:

Here is my situation:

I have a list of entries that i need to group according to their choice

so i get a list of people

Justin "choice1"
Sharon "choice2"
Marisa "choice3"
Joe "choice2"
John "choice3"
etc...

I have another sheet set up like this

choice1
choice2
choice3
choice4
....

i need to copy the cells from sheet 1 to sheet to so it ends up like
this
choice1
Justin
choice2
Sharon
Joe
choice3
Marisa
John
choice4
....
5
....

Can anyone help in this. I can post code but there is more to my
current code than what i am asking for here...i just need a place to
start.

Thanks,

Justin


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Grouping Rows

thanks it works!

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
Grouping Rows Seftyby Excel Worksheet Functions 1 October 3rd 08 02:18 PM
grouping rows AFE Excel Discussion (Misc queries) 1 February 13th 08 12:19 AM
grouping rows... kang New Users to Excel 5 June 10th 07 05:44 PM
Grouping Rows Moz Excel Discussion (Misc queries) 0 July 21st 06 05:33 AM
Grouping rows together Steve-o Excel Worksheet Functions 1 March 23rd 06 06:56 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"