hi all, how are you today?
i have a question on sequence issue, i use my macro to run my employee schedule, however the result return lowest to highest in first column-name
if i request this column-name with my needs(like peter/susan/kelvin instead of kelvin/peter/susan), the macro can not run successfully with all employee. how can i fix this?
i hope you guys would understood my poor english what i am talking about. thanks everyone!
i have a question on sequence issue, i use my macro to run my employee schedule, however the result return lowest to highest in first column-name
if i request this column-name with my needs(like peter/susan/kelvin instead of kelvin/peter/susan), the macro can not run successfully with all employee. how can i fix this?
i hope you guys would understood my poor english what i am talking about. thanks everyone!
VBA Code:
Sub Macro001()
'
' Macro001 Macro
'
'
Sheets("schedule").Select
ActiveSheet.Cells.UnMerge
Dim C As Integer
C = ActiveSheet.Cells.SpecialCells(xlLastCell).Column
Do Until C = 0
If WorksheetFunction.CountA(Columns(C)) = 0 Then
Columns(C).Delete
End If
C = C - 1
Loop
Range("A1").Select
Application.Goto Reference:="R200C1"
ActiveCell.FormulaR1C1 = "END"
Range("A1:A200").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Copy
Sheets("result").Select
Range("A50").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Sheets("schedule").Select
Range("A1").Select
End Sub
Sub Macro002()
'
' Macro002 Macro
'
'
Sheets("result").Select
Dim rDate As Range, rDest As Range
Dim sText1 As String, sText2 As String
Set rDate = Range("c50")
Set rDest = Range("c51")
sText1 = "TEXT(MIN(IFERROR(TIMEVALUE(LEFT(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0)):INDEX('schedule'!$C:$C,MATCH('result'!$A52,'schedule'!$A:$A,0)-1),5)),1)),""hh:mm"")"
sText2 = "TEXT(MAX(IFERROR(TIMEVALUE(MID(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0)):INDEX('schedule'!$C:$C,MATCH('result'!$A52,'schedule'!$A:$A,0)-1),7,5)),0)),""hh:mm"")"
rDest.FormulaArray = "=IF(INDEX('schedule'!$C:$C,MATCH('result'!$A51,'schedule'!$A:$A,0))="""","""",1111&"" - ""&2222)"
rDest.Replace "1111", sText1, LookAt:=xlPart
rDest.Replace "2222", sText2, LookAt:=xlPart
Range("c51").AutoFill Destination:=Range("c51:c" & Range("a" & Rows.Count).End(xlUp).Row)
Range("d51").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=""00:00 - 00:00"",VLOOKUP(RC1,schedule!C1:C9,3,FALSE),"""")"
Range("d51").AutoFill Destination:=Range("d51:d" & Range("a" & Rows.Count).End(xlUp).Row)
End Sub