Solved

creating groups using VBA

Posted on 2011-02-19
8
285 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

790 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