LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   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)

I'm trying to get VBA code to check code numbers (all cells in text format to
keep the initial 0) and then print a header followed by the matching items. The
item descriptions do not need manipulation. I've written some code with
debug.print output that is close to what I need, but I'm not sure how to get the
output to sheet3 and include the item descriptions. Below is the code and
output, followed by the output required and some sample data. Any help greatly
appreciated.

Sub GettingCloser()
Dim MyCodesArray As Integer
Sheet2.Range("A2:A11").Name = "MyCodesArray"
Sheet2.Range("E2:E6").Name = "MyGroupsArray"
For Each groupcell In Range("MyGroupsArray")
Debug.Print "Group "; groupcell; " items"
For Each codecell In Range("MyCodesArray")
If Left(codecell, 3) = groupcell Then
Debug.Print codecell
End If
Next codecell
Next groupcell
End Sub

Group 010 items
01050
Group 013 items
01315
Group 025 items
02530
02550
Group 033 items
03360
03370
03390
Group 042 items
04200
04220
04260

The output I need to end up with is as follows and below that is some sample data
I'm working with.:

Sheet3
Group 010 Items
01050 item 01050

Group 013 Items
01315 item 01315

Group 025 Items
02530 item 02530
02550 item 02550

Group 033 Items
03360 item 03360
03370 item 03370
03390 item 03390

Group 042 Items
04200 item 04200
04220 item 04220
04260 item 04260

-- 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 09:45 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"