ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format by VB opened Workbooks/sheets (https://www.excelbanter.com/excel-programming/301403-format-vbulletin-opened-workbooks-sheets.html)

exceller

Format by VB opened Workbooks/sheets
 
Okay, here we go:

The code I have written so far opens a range of workbooks selected by
multi-select listbox and single-select listbox.

Now I want to apply formatting to the opened workbooks, includin
adding worksheets, setting autofilters sorting the data and then savin
the workbooks as .xls files.

Example:
VB has opened files File1_a.csv, File1_b.csv and File1_c.csv from th
first (multi select) listbox and File2_a.xls from the (single select
listbox, so 4 files have been opened.

Now I want to call function1 to format all open File1_*.csv files an
copy-paste File1_*.csv ranges into different sheets of the File2_a.xl
file.

Function1 contains code as recorded in Excel.

Can I declare/activate open workbooks by name (such as File1_*.csv) an
then call the function on each individual open workbook meeting th
file name criteria?

I am eternally gratefull to anyone who can help me further on thi
(last for my current project) vb problem!

Thanks,
Joos

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Format by VB opened Workbooks/sheets
 
Based on the details provided,

Turn on the macro recorder

open one of the CSV files.

Perform all the required actions.

Turn off the macro recorder. Adjust the recorded code to generalize it and
compact it (remove unnecessary statements)

--
Regards,
Tom Ogilvy

"exceller " wrote in message
...
Okay, here we go:

The code I have written so far opens a range of workbooks selected by a
multi-select listbox and single-select listbox.

Now I want to apply formatting to the opened workbooks, including
adding worksheets, setting autofilters sorting the data and then saving
the workbooks as .xls files.

Example:
VB has opened files File1_a.csv, File1_b.csv and File1_c.csv from the
first (multi select) listbox and File2_a.xls from the (single select)
listbox, so 4 files have been opened.

Now I want to call function1 to format all open File1_*.csv files and
copy-paste File1_*.csv ranges into different sheets of the File2_a.xls
file.

Function1 contains code as recorded in Excel.

Can I declare/activate open workbooks by name (such as File1_*.csv) and
then call the function on each individual open workbook meeting the
file name criteria?

I am eternally gratefull to anyone who can help me further on this
(last for my current project) vb problem!

Thanks,
Joost


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com