Nillus
Nillus

Reputation: 3

Send User Form in Excel to another Workbook?

I am very new to VB coding and creating forms in Excel. I have created a very simple form in Excel that now captures user data and saves to a sheet within the Form's workbook. Is there a way to code the command button so that it will save the user data to separate workbook that is saved on a network server?

Upvotes: 0

Views: 3795

Answers (1)

Bruno Leite
Bruno Leite

Reputation: 1477

One way is open other workbook and insert data, for example

Sub ExtractData()

Dim nwb As Workbook

Set nwb = Workbooks.Open("\\Your\Server\Path\YourFile.xlsx")

With nwb.Sheets(1)
    .Range("A1").Value = YourForm.Textbox1.Text
    .Range("B1").Value = YourForm.Textbox2.Text
    .Range("C1").Value = YourForm.Textbox3.Text
End With

nwb.Close True

End Sub

you can also use ADO to use Insert statement with TSQL, to create a connection see this

Upvotes: 1

Related Questions