I have an Excel user form and some Excel VBA code that transforms some of the worksheet data into a format ready for import to an Access application. The code works fine but I've decided that it would be much better for development and operations if the form and code were moved over to reside within the Access application, rather than the spreadsheet.
Where can I learn how to convert my Excel VBA code to work within Access or at least where is a reference on coding to process Excel within Access VBA?
Based solely on VBA ACCESS - Loop Excel workbooks I have so far managed to start with this (Note: all of the following are just snippets.):
Private source_empl_col As Integer
Private xl_app As Object
Set xl_app = CreateObject("Excel.Application")
xl_app.Workbooks.Open (workbook_txt)
and I've managed to convert
Private source_sheet As Worksheet
Set source_sheet = Worksheets(source_cbo.Text)
source_sheet.Activate
Dim ws As Integer
For ws = 1 To Worksheets.Count
source_cbo.AddItem Worksheets(ws).Name
from Excel VBA into Access VBA
xl_app.Sheets(source_cbo).Activate
Dim ws As Integer
For ws = 1 To xl_app.Worksheets.Count
source_cbo.AddItem xl_app.Worksheets(ws).Name
without error. However, when it comes to converting
source_empl_col = Range(empl_col_txt & 1).Column
from Excel VBA into Access VBA
source_empl_col = xl_app.Sheets(source_cbo).Range(empl_col_txt.Text & 1).Column
or even just
source_empl_col = xl_app.Sheets(source_cbo).Range("B1").Column
I get
Run-time error: '91'
Object variable ... not set.
There's just too much code that I need to translate so it works within Access without knowing what I'm doing. Some guidance is needed!