Export into an Excel Template (1 Viewer)

Locopete99

Registered User.
Local time
Yesterday, 19:51
Joined
Jul 11, 2016
Messages
163
Hi Guys.

I have need on my database to export some information into an Excel template to e-mail to another department for them to do some work on.

It needs to be Excel so they can upload the information onto the companies system.

I can export to excel, but can you export to an existing excel template and specify what cell the information should start being exported into, for example cell A4 taking into account headers etc on the spreadsheet.
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:51
Joined
Sep 21, 2011
Messages
14,417
Not export as such I don't think, but you can use VBA to populate the cells
Below is some code I use to do just that, although I save it as a csv file

HTH
Code:
SetStatusBar ("Creating Xero Invoice Import file ")
' Now create a workbook for invoicing to Xero
wbs.Open (strPath & strXeroTemplate)
Set ws = XLApp.ActiveWorkbook.ActiveSheet
strInvAccount = "001"
strInvNum = "JL-" & Format(Now(), "yymmdd")
iRow = 2
rst.MoveFirst
Do While Not rst.EOF
    ' Set the Excel data cells
    With ws
        .Range("A" & iRow).Value = "Company name"
        .Range("K" & iRow).Value = strInvNum
        .Range("L" & iRow).Value = "Type of payment"
        .Range("M" & iRow).Value = Format(Date, "dd/mm/yyyy")
        .Range("N" & iRow).Value = Format(Date + 7, "dd/mm/yyyy")
        .Range("P" & iRow).Value = " Fee"
        .Range("Q" & iRow).Value = rst!Client & " - " & Format(Int(rst!LinkedAmount), "£#,###,##0.00")
        .Range("R" & iRow).Value = 1
        .Range("S" & iRow).Value = Format(rst!AppliedAmount, "£##0.00")
        .Range("U" & iRow).Value = strInvAccount
        .Range("V" & iRow).Value = "No VAT"
    End With
    iRow = iRow + 1
    rst.MoveNext
Loop
XLApp.ActiveWorkbook.SaveAs FileName:=strInvoicePath & "Xero Just Loans Import File.csv", FileFormat:=xlCSV
XLApp.ActiveWorkbook.Close Savechanges:=False
MsgBox "Xero Invoice import file created in " & strInvoicePath
SetStatusBar (" ")
 

Locopete99

Registered User.
Local time
Yesterday, 19:51
Joined
Jul 11, 2016
Messages
163
Thanks, I'll give it a go!
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:51
Joined
Sep 21, 2011
Messages
14,417
Thanks, I'll give it a go!

Don't just copy it like some people do, you need to look to see how it works and tailor to your situation.
It has the basics though, to at least get you started.
 

Locopete99

Registered User.
Local time
Yesterday, 19:51
Joined
Jul 11, 2016
Messages
163
I can't get on with just copying and pasting. I like to go through it and make sure I know what it does and also as you say, change it to suit my situation.
 

Users who are viewing this thread

Top Bottom