Tried all over the intenet to figure out this one.
What i am doing is i have a command button on Access Form. On Click [Event Procedure] calls a macro (module). Macro calls a query and exports to excel. Macro then runs on the worksheet. After i run this one time, for all future times i must manually press the reset button.
Dim shta As Worksheet <-- also tried as Excel.Worksheet
...
set shta = ActiveSheet
lastrow = shta.Cells(shta.Rows.Count, "A").End(xlUp).Row <--errors out. I tried removing the shta. from and still it gives me new error at this line.
...
Exit Procedure:
....
If Not shta Is Nothing Then Set shta = Nothing <--tried this too
....
Exit Sub
....
FYI. i skipped over this code and when got to line Sheets.Add.Name = "n": resulted in 1004 Application-defined or object-defined error.
What i am doing is i have a command button on Access Form. On Click [Event Procedure] calls a macro (module). Macro calls a query and exports to excel. Macro then runs on the worksheet. After i run this one time, for all future times i must manually press the reset button.
Dim shta As Worksheet <-- also tried as Excel.Worksheet
...
set shta = ActiveSheet
lastrow = shta.Cells(shta.Rows.Count, "A").End(xlUp).Row <--errors out. I tried removing the shta. from and still it gives me new error at this line.
...
Exit Procedure:
....
If Not shta Is Nothing Then Set shta = Nothing <--tried this too
....
Exit Sub
....
FYI. i skipped over this code and when got to line Sheets.Add.Name = "n": resulted in 1004 Application-defined or object-defined error.
Last edited: