Hi people,
I'm new to VBA. I have created a userform that successfully submits to another sheet in the same workbook. However, I want to replicate the user form so that 15 or so users can submit their end of day KPIs to a worksheet in a separate, shared workbook - if only macro-enabled workbooks could be shared!
I want the submission button on the user form to do the following:
Here is my code:
The form seems to correctly open the destination workbook.
However, i get a 438 run-time error 'Object doesn't support this property or method' at the line:
'.nwb.emptyRow ='
I also get a whole lot of out of memory errors when i try to run the form again from within the debugger. I think my code is nearly there, but just jumbled enough to not work.
Any suggestions on what i'm doing wrong?
I'm new to VBA. I have created a userform that successfully submits to another sheet in the same workbook. However, I want to replicate the user form so that 15 or so users can submit their end of day KPIs to a worksheet in a separate, shared workbook - if only macro-enabled workbooks could be shared!
I want the submission button on the user form to do the following:
- Change the workbook
- Select the correct sheet in the new workbook
- Determine the empty row
- Transfer the information from that form to the empty row
Here is my code:
Code:
Private Sub Button_Submit_Click()
'Change Workbook
Dim nwb As Workbook
Set nwb = Workbooks.Open("G:\Time to Complete Tracker - Destination Workbook.xlsx")
'Make Daily_Tracking_Dataset active
nwb.Sheets("daily_tracking_dataset").Activate
'Determine emptyRow
Dim emptyRow As Long
nwb.emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer Information
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 1).Value = TextBox1.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 2).Value = lstName.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 3).Value = txtROIT.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 4).Value = txtROISub.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 5).Value = txtRefsT.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 6).Value = txtRefsC.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 7).Value = txtRefsSub.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 8).Value = txtReSubT.Value
nwb.Sheets("daily_tracking_dataset").Cells(emptyRow, 9).Value = txtReSubSub.Value
End Sub
The form seems to correctly open the destination workbook.
However, i get a 438 run-time error 'Object doesn't support this property or method' at the line:
'.nwb.emptyRow ='
I also get a whole lot of out of memory errors when i try to run the form again from within the debugger. I think my code is nearly there, but just jumbled enough to not work.
Any suggestions on what i'm doing wrong?