Question about excel macros + VBA.
I have a button that activates a Macro and creates a new line of data in a new sheet. The thing is that I want it to create a new line only if the finish date is more recent than the start date. I tried calling the Macro inside the VBA code but nothing happens.
If I try using the IF inside the macro, it just gives the error in the Msgbox, but no line is added even if conditions are met.
The Macro is working just fine, the IF statement does nothing as is.
The code I tried using:
Sub ButtonStuff()
If Range("H13").Value > Range("H7").Value Then
Call Macro15
Else
If Range("H13").Value <= Range("H7").Value Then
MsgBox "End date cannot be previous to Start date"
End If
End If
End Sub
Sub Macro15()
'
' Macro15 Macro
'
'
Range("H5,H7,H9,H11,H13").Select
Range("H13").Activate
Selection.Copy
Sheets("Data").Select
Columns("A:A").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Incident Report").Select
Range("H5,H9,H11").Select
Range("H11").Activate
Application.CutCopyMode = False
Selection.ClearContents
Range("N8").Select
Selection.Copy
Range("H7").Select
Range("H7").Activate
ActiveSheet.Paste
Range("N9").Select
Selection.Copy
Range("H13").Select
Range("H13").Activate
ActiveSheet.Paste
Range("H5").Select
End Sub
Thanks!