N
Neil Pearce
I have recorded the Sub "Add_to_List" as detailed below and attached it to a
button on my spreadheet.
What lines would be required to add the condition that the macro will only
proceed:
IF cell D4010 is a date AND cells F4010 & G4010 are interger numbers
Carryout Macro ADD_TO_LIST
ELSE provide a messagebox that states, "Cell D4010 must be a date AND cells
F4010 & G4010 must be interger numbers"
Many thanks
Neil
Sub ADD_TO_LIST()
'
' ADD_TO_LIST Macro
' Macro recorded 12/11/2009 by Gleeds
'
'
Range("D4010:H4010").Select
Selection.Copy
Range("D4008").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D8:H4008").Select
Range("H4008").Activate
Application.CutCopyMode = False
Selection.Sort Key1:=Range("D9"), Order1:=xlDescending,
Key2:=Range("F9") _
, Order2:=xlAscending, Key3:=Range("G9"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("D4011:H4011").Select
Selection.ClearContents
ActiveWindow.ScrollRow = 9
Range("A1").Select
End Sub
button on my spreadheet.
What lines would be required to add the condition that the macro will only
proceed:
IF cell D4010 is a date AND cells F4010 & G4010 are interger numbers
Carryout Macro ADD_TO_LIST
ELSE provide a messagebox that states, "Cell D4010 must be a date AND cells
F4010 & G4010 must be interger numbers"
Many thanks
Neil
Sub ADD_TO_LIST()
'
' ADD_TO_LIST Macro
' Macro recorded 12/11/2009 by Gleeds
'
'
Range("D4010:H4010").Select
Selection.Copy
Range("D4008").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D8:H4008").Select
Range("H4008").Activate
Application.CutCopyMode = False
Selection.Sort Key1:=Range("D9"), Order1:=xlDescending,
Key2:=Range("F9") _
, Order2:=xlAscending, Key3:=Range("G9"), Order3:=xlAscending,
Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("D4011:H4011").Select
Selection.ClearContents
ActiveWindow.ScrollRow = 9
Range("A1").Select
End Sub