ibschleime
New Member
- Joined
- Jan 21, 2005
- Messages
- 4
Ok, I know I can use =now() to get the time and date, but I am working with timecards and need to calculate a labor percentage based on the current time. I am removing the date from =now() by copying the cell and pasting the value. Then I replaced the spaces between the date and time with a comma and split them into two cells so I could use only the time. It works when I do it manually, but the macro doesn't work. Can anyone help me?
Here is what I did:
Range("L1").Select
Selection.NumberFormat = "General"
ActiveCell.FormulaR1C1 = "=NOW()"
Range("L1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("L1").Select
ActiveCell.Replace What:=" ", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:=" ", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Columns("M:M").EntireColumn.AutoFit
Range("A1").Select
ActiveCell.FormulaR1C1 = "=RC[12]"
Range("A1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("L1:M1").Select
Selection.ClearContents
Selection.NumberFormat = "General"
Range("L9").Select
End Sub
thanks!!! i need help!!!
Here is what I did:
Range("L1").Select
Selection.NumberFormat = "General"
ActiveCell.FormulaR1C1 = "=NOW()"
Range("L1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("L1").Select
ActiveCell.Replace What:=" ", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Find(What:=" ", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Columns("M:M").EntireColumn.AutoFit
Range("A1").Select
ActiveCell.FormulaR1C1 = "=RC[12]"
Range("A1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("L1:M1").Select
Selection.ClearContents
Selection.NumberFormat = "General"
Range("L9").Select
End Sub
thanks!!! i need help!!!