Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Re-use Excel macro
Hello:
Do know how I can re-use an Excel macro. For example, I have imported a tab delimited ASCII file into Excel and recorded the process in a macro. Is it possible to use that macro to import other tab delimited ASCII files(so open the macro and open another file using the macro without having to go through the wizard - the wizard is automatically opened because of the tab delimiters so that the user can choose the kind of delimiter and set the data format type, if necessary, for the columns) Thanks Jade |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Re-use Excel macro
Yep.
I like to create a dedicated macro workbook that contains the code. And then I put a big button from the Forms toolbar on the only worksheet in that workbook. I'll add a few instructions to that sheet, too. Then I can distribute this macro workbook to other users (and use it myself) so that I can just click the giant button to invoke the macro that imports the text file. I'd tweak the code to get the name of the file to open from the user and then include code that adds some more stuff--like formatting, filters, subtotals, page setup (headers/footers/rows to repeat at top/etc). Then it actually becomes a tool that makes life a lot easier. My tweaked code could look a little like: Option Explicit Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.OpenText Filename:=myFileName '....rest of recorded code here! End Sub Jade5 wrote: Hello: Do know how I can re-use an Excel macro. For example, I have imported a tab delimited ASCII file into Excel and recorded the process in a macro. Is it possible to use that macro to import other tab delimited ASCII files(so open the macro and open another file using the macro without having to go through the wizard - the wizard is automatically opened because of the tab delimiters so that the user can choose the kind of delimiter and set the data format type, if necessary, for the columns) Thanks Jade -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel application.quit in macro problem | New Users to Excel | |||
How to stop Excel remembering/loading macro from previously opened Workbook | Excel Discussion (Misc queries) | |||
Macro Help In Excel | Excel Discussion (Misc queries) | |||
Closing File Error | Excel Discussion (Misc queries) | |||
passing arguments from an excel macro to a word macro | Excel Discussion (Misc queries) |