Somnolence81
Technical User
I am working on combining a macro that converts integers that are simulated to be in a time format, into an actual format( this one works, we have been using it for over 4 years with no trouble other than it is slow). and a new macro that checks for data in the columns A,Q,R,S,T,U,V and W adjacent to a selected range for blank or not, then autofills from the above row in said columns, assuming that the cell referenced in the selection also contains data, after reading a few answers I noticed a familiar mantra of not using the .select function. I have it at least three times per said column, and when I try to clean it up, I get any number of errors from range to object... The last scripting I did was over fifteen years ago and in a different language, so consider me a novice... I want to bind these macros to a hotkey so that they will both run sequentially and here is what I have so far:
'in Module 2:
'in module 1:
Any help would be greatly appreciated, also when trying to combine the codes, aplication.screenupdate=false doesn't seem to work in any combination of in each macro, in only mastercall, or all of the above... any ideas? thanks in advance
'in Module 2:
Code:
Sub MasterCallMacros()
Call NumberToTime
Call ReturnSelection
End Sub
'in module 1:
Code:
Sub NumberToTime()
Application.ScreenUpdating = False
Dim rCell As Range
Dim iHours As Integer
Dim iMins As Integer
x = x
For Each rCell In Selection
If rCell.Value = "" Then x = x + 1
If rCell.NumberFormat = "hh:mm" And rCell.Value = "" Then rCell.NumberFormat = "0#"":""##;@"
x = x + 1
If IsNumeric(rCell.Value) And Len(rCell.Value) > 0 And rCell.NumberFormat <> "hh:mm" Then
iHours = rCell.Value \ 100
iMins = rCell.Value Mod 100
rCell.Value = (iHours + iMins / 60) / 24
rCell.NumberFormat = "hh:mm"
End If
Next
Application.ScreenUpdating = True
End Sub
'in module 3:
[CODE]
Option Explicit
Sub ReturnSelection()
Application.ScreenUpdating = False
Dim ActSheet As Worksheet
Dim rCell As Range
Set ActSheet = ActiveSheet
Set rCell = Selection
For Each rCell In Selection
If Range("A" & (ActiveCell.Row)).Value <> "" Then
ActSheet.Select
rCell.Select
Else
If Range("A" & (ActiveCell.Row)).Value = "" Then
Range("A" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("Q" & (ActiveCell.Row)).Value = "" Then
Range("Q" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("R" & (ActiveCell.Row)).Value = "" Then
Range("R" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("S" & (ActiveCell.Row)).Value = "" Then
Range("S" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("T" & (ActiveCell.Row)).Value = "" Then
Range("T" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("U" & (ActiveCell.Row)).Value = "" Then
Range("U" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("V" & (ActiveCell.Row)).Value = "" Then
Range("V" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Range("w" & (ActiveCell.Row)).Value = "" Then
Range("w" & (ActiveCell.Row)).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next
Application.ScreenUpdating = True
End Sub
Any help would be greatly appreciated, also when trying to combine the codes, aplication.screenupdate=false doesn't seem to work in any combination of in each macro, in only mastercall, or all of the above... any ideas? thanks in advance