-
I'm currently using Excel as part of a school project, I need to know how to get info from a text box in userform, to a specific cell in a workbook. Can anyone please help me, since quite a bit of the project is based on this feature of people entering data into user frorm created through the visual basic part, and it moving to the spreadsheet.
Thankyou
-
Hi.
In references, put a reference to Microsoft Excel 9.0 Library.
Then code
Dim xlsWorkBook As Excel.Workbook
Dim xlsWorkSheet As Excel.Worksheet
Command1_Click()
Set xlsWorkBook = GetObject("C:\MyDocuments\whatever.xls")
Set xlsWorkSheet = xlsWorkBook.Worksheets("Sheet1")
xlsWorkSheet.Cells(1, 1).value = Text1.Text 'This represent cell A1.
xlsWorkSheet.Cells(2, 1).value = Text2.Text 'This represent cell A2
xlsWorkSheet.Cells(1, 2).value = Text3.Text 'This represent cell B2
'when you're finished
xlsWorkBook.Close
End Sub
I think that's about it