JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
Overview: Macro to open various data source files and create CSV sheets to independently save down
Process: Open source files, extract data, close file
Problem: Some source files contain data not needed or after extracting data, post process is required.
For this example, Timesheet is sheet name and function specific for it is:
All sheets that require a pre step, I name their specific function (or sub) Pre_<sheet name> (similarly for any sheets requiring post import work, Post_<name>).
In my code, I have
Line in red errors: "Cannot run the macro 'Pre_Timesheet (sWks)'. The macro may not be available in this workbook or.."
Tried searching online, came across Application.Run, CallByName but I can't get them to work for my requirement.
Can anyone suggest how I to indirectly call a function with required argument for example above?
Thank you in advance,
Jack
Overview: Macro to open various data source files and create CSV sheets to independently save down
Process: Open source files, extract data, close file
Problem: Some source files contain data not needed or after extracting data, post process is required.
For this example, Timesheet is sheet name and function specific for it is:
Rich (BB code):
Public Function Pre_Timesheet(ByRef wks As Worksheet) As Worksheet
'code to remove unwanted data before importing
End Function
In my code, I have
Rich (BB code):
Const PRE_ as String = "Sheet1|Sheet2|Sheet3"
If Instr(PRE_, wks.Name) Then
Str = Replace("Pre_@1 (wks)", "@1", wks.name)
Set wks = Application.Run Str
End If
Tried searching online, came across Application.Run, CallByName but I can't get them to work for my requirement.
Can anyone suggest how I to indirectly call a function with required argument for example above?
Thank you in advance,
Jack