albertc30
Well-known Member
- Joined
- May 7, 2012
- Messages
- 1,091
- Office Version
- 2019
- Platform
- Windows
Hi all.
The code bellow was working fine with data 1 to 4 as variant, Invoices range A1 to D1 and Resize(1, 4)).
I since added another value go to another column and all still works but the value in Data4 is not being copied across.
This has now done my head in. I'll be checking this in the morning as I need my sleep now. It's 02:12 here in the UK and after a full on days work I am shattered.
As always, many thanks for all the time and help given. Cheers.
The code bellow was working fine with data 1 to 4 as variant, Invoices range A1 to D1 and Resize(1, 4)).
I since added another value go to another column and all still works but the value in Data4 is not being copied across.
This has now done my head in. I'll be checking this in the morning as I need my sleep now. It's 02:12 here in the UK and after a full on days work I am shattered.
VBA Code:
Private Sub CBProfoInvoice_Click()
Beep
If MsgBox("You have selected a proforma invoice document." & vbNewLine & "This will generate your next invoice?", vbQuestion + vbYesNo, "Proforma to Invoice...") = vbNo Then
Exit Sub
End If
'save invoice pdf code below
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"D:\Software\Invoices\INV" & Range("F4").Text & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Dim Data(1 To 5) As Variant
Dim DstRng As Range
Dim RngEnd As Range
Set DstRng = Worksheets("Invoices").Range("A1:E1")
Set RngEnd = DstRng.Parent.Cells(Rows.Count, DstRng.Column).End(xlUp)
Set DstRng = IIf(RngEnd.Row < DstRng.Row, DstRng, RngEnd.Offset(1, 0).Resize(1, 5))
With Worksheets("Create")
Data(1) = .Range("F4") 'Invoice number
Data(2) = .Range("C12") 'Invoice total
Data(3) = .Range("C14") 'Deposit
Data(4) = .Range("C16") 'Owed
Data(5) = .Range("F3") 'Proforma Number THIS IS NOT BEING COPIED ACROSS!!!
End With
DstRng = Data
CBGenDocument.Enabled = False
CBProfoInvoice.Enabled = False
Sheets("Create").Select
End Sub
As always, many thanks for all the time and help given. Cheers.