L
Legacy 436357
Guest
Hi,
I have this code which runs when cell H46 is changed. What I would like to do is have this code run by a button instead which also saves the print area B2:H53 of this sheet 'Lookup Invoice' to a PDF file.
Is this possible to do and if so how please?
Thank you very much
I have this code which runs when cell H46 is changed. What I would like to do is have this code run by a button instead which also saves the print area B2:H53 of this sheet 'Lookup Invoice' to a PDF file.
Is this possible to do and if so how please?
Thank you very much
Code:
Dim xVal As String
Private Sub Worksheet_Change(ByVal Target As Range)
Static xCount As Integer
Application.EnableEvents = False
If Target.Address = Range("H46").Address Then
Range("J3").Offset(xCount, 0).Value = Range("H46").Value
Range("K3").Offset(xCount, 0).Value = Range("H3").Value
Range("L3").Offset(xCount, 0).Value = Format(Now(), "HH:MM:SS")
xCount = xCount + 1
Else
If xVal <> Range("H44").Value Then
Range("J3").Offset(xCount, 0).Value = Range("H46").Value
Range("K3").Offset(xCount, 0).Value = Range("H3").Value
Range("L3").Offset(xCount, 0).Value = Format(Now(), "MM/dd/yyyy HH:MM:SS")
xCount = xCount + 1
End If
End If
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
xVal = Range("H46").Value
End Sub
Last edited by a moderator: