brilliantblk
07-24-2012, 09:33 AM
So far, I have a input box that asks the user how many groups he has. I have my spreadsheet setup with formulas such that, for example, if the user inputs 5 groups, five columns will populate with the header Group 1, Group 2, Group 3, etc. Hidden above these cells are the numbers 1-25 (max 25 groups), that is used in an IF statement that if that cell is less than the number of groups the user entered, write below the cell "Group" and the number. Under each of the headers is a cell to enter the number of employees. I am trying to incorporate that into my macro and here is what I have so far. Needless to say, I am VERY VERY VERY new to VBA and do not know the extent of the commands that I can use; this made sense in my head but apparently doesn't work too well:
Do
If ActiveCell.Value < SumOfGroup And ActiveCell.Value <> "" Then Exit Do
'ActiveCell.Offset(2, 0).Activate
Range(ActiveCell.Offset(2, 0)).Value = InputBox("Enter the number of employees in Group " & ActiveCell.Value)
ActiveCell.Offset(-2, 1).Activate
Loop
So in my mind, first it selects the hidden active cell containing 1. The If statement is proven true. It then activates the cell to enter the number of employees into Group 1. User inputs the value, and the loop continues to 2 and repeats until the value is greater than the number of groups.
Do
If ActiveCell.Value < SumOfGroup And ActiveCell.Value <> "" Then Exit Do
'ActiveCell.Offset(2, 0).Activate
Range(ActiveCell.Offset(2, 0)).Value = InputBox("Enter the number of employees in Group " & ActiveCell.Value)
ActiveCell.Offset(-2, 1).Activate
Loop
So in my mind, first it selects the hidden active cell containing 1. The If statement is proven true. It then activates the cell to enter the number of employees into Group 1. User inputs the value, and the loop continues to 2 and repeats until the value is greater than the number of groups.