vishal0589
Board Regular
- Joined
- May 13, 2014
- Messages
- 63
Hi Friends,
Hope you are doing well.
I need your assistance in this problem.
I want to randomised placement of centain Text values to sepcific rows based on cell value.
Let me clear about my problem.
I have setup a sheet which records attendence of employees.
An employee could takeup a leave,holidays and there will be weeklyoffs too.
I have created a Macro which record attendence based on Leaves (CL/EL), Holidays, and Weekly offs.
Macro:
Private Sub CommandButton1_Click()
Dim a As Range
Dim mx As Integer
Dim tot As Integer
Dim Rw As Long
tot = 0
For Rw = 10 To (Sheet1.[match(2,1/(b10:b4116<>""))] + 9)
For i = 12 To 41
Dim r As Integer
r = Int((41 - 12 + 1) * Rnd() + 12) 'truncate the random number to an integer
Cells(Rw, i).Value = "P" 'set the value in the cell to this random number
Next i
'mx = Cells(Rw, 5).Value Have to check..
For i = 1 To 4
r = Int((41 - 12 + 1) * Rnd() + 12)
tot = tot + r
Cells(Rw, r).Value = "CL" 'set the value in the cell to this random number
Next i
For i = 1 To 3
r = Int((41 * Rnd) + 12) 'truncate the random number to an integer
Cells(Rw, r).Value = "EL" 'set the value in the cell to this random number
Next i
Next Rw
MsgBox "Done!"
End Sub
But my problem is that random placment of leaves,holidays,or wweklyoffs are not based on specific count.
e.g:
If there is month of 30 days and employee have taken 4 Leaves, there is holiday for 2 days and Weekly Offs are about 3 days.
then
Placement is not randomised properly based on leaves,holidays and weeklyoffs in 30 days.
My macro is not based on fixed cell value (I think).
But It gives accurate result in sum of total days i.e. 30 Days.
I have also attached a link of my sample sheet. Please help me out.
FileChucker
Thanks in Advance
Vishal Srivastava
Hope you are doing well.
I need your assistance in this problem.
I want to randomised placement of centain Text values to sepcific rows based on cell value.
Let me clear about my problem.
I have setup a sheet which records attendence of employees.
An employee could takeup a leave,holidays and there will be weeklyoffs too.
I have created a Macro which record attendence based on Leaves (CL/EL), Holidays, and Weekly offs.
Macro:
Private Sub CommandButton1_Click()
Dim a As Range
Dim mx As Integer
Dim tot As Integer
Dim Rw As Long
tot = 0
For Rw = 10 To (Sheet1.[match(2,1/(b10:b4116<>""))] + 9)
For i = 12 To 41
Dim r As Integer
r = Int((41 - 12 + 1) * Rnd() + 12) 'truncate the random number to an integer
Cells(Rw, i).Value = "P" 'set the value in the cell to this random number
Next i
'mx = Cells(Rw, 5).Value Have to check..
For i = 1 To 4
r = Int((41 - 12 + 1) * Rnd() + 12)
tot = tot + r
Cells(Rw, r).Value = "CL" 'set the value in the cell to this random number
Next i
For i = 1 To 3
r = Int((41 * Rnd) + 12) 'truncate the random number to an integer
Cells(Rw, r).Value = "EL" 'set the value in the cell to this random number
Next i
Next Rw
MsgBox "Done!"
End Sub
But my problem is that random placment of leaves,holidays,or wweklyoffs are not based on specific count.
e.g:
If there is month of 30 days and employee have taken 4 Leaves, there is holiday for 2 days and Weekly Offs are about 3 days.
then
Placement is not randomised properly based on leaves,holidays and weeklyoffs in 30 days.
My macro is not based on fixed cell value (I think).
But It gives accurate result in sum of total days i.e. 30 Days.
I have also attached a link of my sample sheet. Please help me out.
FileChucker
Thanks in Advance
Vishal Srivastava