LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default group rows in a range based on criteria from another range (vba)

Made some modifications to the code and I'm closer, but need some help on getting
the right description cell to sheet3. Below is the new code and resulting
output:

Sub GettingCloser()
Sheet2.Range("A2:B10").Name = "MyCodesArray"
Sheet2.Range("E2:E6").Name = "MyGroupsArray"
For Each groupcell In Range("MyGroupsArray")
Sheets("Sheet3").Range("A1").Offset(iCol, 0) = "Group " & groupcell & "
items"
iCol = iCol + 1
For Each codecell In Range("MyCodesArray")
desccell = Range("MyCodesArray").Cells(1, 2)
If Left(codecell, 3) = groupcell Then
Sheets("Sheet3").Range("A1").Offset(iCol, 0) = codecell
Sheets("Sheet3").Range("A1").Offset(iCol, 1) = desccell
iCol = iCol + 1
End If
Next codecell
iCol = iCol + 1
Next groupcell
End Sub

Group 010 items
01050 item 01050

Group 013 items
01315 item 01050

Group 025 items
02530 item 01050
02550 item 01050

Group 033 items
03360 item 01050
03370 item 01050
03390 item 01050

Group 042 items
04200 item 01050
04220 item 01050


-- Sample Data --
Sheet2.Range("A2:A11").Name = "MyCodesArray"
Code Description
01050 item 01050
01315 item 01315
02530 item 02530
02550 item 02550
03360 item 03360
03370 item 03370
03390 item 03390
04200 item 04200
04220 item 04220
04260 item 04260

Sheet2.Range("E2:E6").Name = "MyGroupsArray"
Group
010
013
025
033
042




 
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
Summing a range of cells based on criteria in another range Jack Excel Worksheet Functions 2 November 5th 09 01:46 AM
Need sum of top values in a range based on criteria CSchwass Excel Worksheet Functions 5 August 28th 09 11:09 PM
Summing based on a range of criteria Mike Excel Discussion (Misc queries) 3 June 16th 09 07:05 PM
Sum based on Range Criteria ddate Excel Worksheet Functions 2 August 3rd 07 10:16 PM
MIN within range based on criteria StevenL Excel Discussion (Misc queries) 9 July 11th 05 11:33 PM


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