Solved

creating groups using VBA

Posted on 2011-02-19
8
279 Views
Last Modified: 2012-08-14
Hello,
I have provided the fields that I am using and what I need returned.  I need to organize 12 students into two project teams using their birthday (year is not important) I need to use If/Then  statements for project 1 to categorize the people into two groups born Jan1-June 30th marking them as "Group 1" and then categorize the people born July 1-Dec 30 as "Group 2".  they need to be called in column called in the project 1 column.  For project 2 I need to use select case statement.  "Group A" for this project should include people born January 1-March 31, "Group B" should include people born April 1-June 30.... etc.  

Last Name	First Name	Birthday	UID     	Project 1 team      Project 2 team
Doe      	John     	9/25/1973	U16253817		
Doe     	Jane     	8/2/1982	U55990265		
Doe     	Juile     	7/26/1986	U28098838		
Doe     	Joe     	12/22/1973	U55098179		
Doe     	Jessica     	11/25/1970	U42647584		
Doe     	Jole     	12/20/1979	U79697656		
Doe     	Jumper     	1/13/1971	U73549073		
Doe     	Justin     	5/7/1984	U69504570		
Doe     	Joel     	6/1/1975	U44076419		
Doe     	Jule     	5/2/1983	U61142789		
Doe     	Jeep     	5/7/1978	U11856501		
Doe     	Jolie     	4/3/1987	U17426253

Open in new window

           
   
0
Comment
Question by:maudette
  • 3
8 Comments
 

Author Comment

by:maudette
ID: 34934325
anyone?
0
 
LVL 8

Accepted Solution

by:
Toxacon earned 250 total points
ID: 34936237
Try this:

Option Explicit

Sub ArrangeGroups()
    Dim iLoop As Integer, Month As Integer
    For iLoop = 2 To 13
        Month = DatePart("M", Worksheets("Sheet1").Cells(iLoop, 3).Value)
        If Month < 7 Then
            Worksheets("Sheet1").Cells(iLoop, 5).Value = "X"
        Else
            Worksheets("Sheet1").Cells(iLoop, 6).Value = "X"
        End If
    Next
End Sub

Open in new window

0
 
LVL 30

Assisted Solution

by:SiddharthRout
SiddharthRout earned 250 total points
ID: 34936976
No need for VBA. Here is a sample attached.

If your data is from say cell A1 to F13 then this formula will go

in E2

=IF(VALUE(TEXT(C2,"m"))<7,"Group1","Group2")

and this

in F2

=IF(VALUE(TEXT(C2,"m"))<4,"GroupA",IF(VALUE(TEXT(C2,"m"))<7,"GroupB",IF(VALUE(TEXT(C2,"m"))<10,"GroupC","GroupD")))

Sid

Grouping.xls
0
 

Author Comment

by:maudette
ID: 35215549
Please Close
0
 

Author Comment

by:maudette
ID: 35215567
Close
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question