tags:

views:

60

answers:

1

I'm looking for a simple way to recreate a relatively complex Excel sheet with a macro, inculding cell values, formulas, formatting, and cell size.

Basically, I have an Excel sheet and I need the VB code that would create the sheet. I.e. somewhat like using the macro recorder, but without having to do all the steps in sequence.

Any ideas?

(Copying from a template xls would be much more convenient, of course, but I'm limited to code and can't use additional files in production, for now).

A: 

If you don't want to use additional files, put your template as a separate sheet in the same XLS where your macro resides. IMHO, you should avoid having to recreate a complete sheet by code, at least for maintenance reasons.

Doc Brown
Well, atm I can only ship code (essentially, its a reporting tool that fills a fresh sheet with some db output and calls a macro).Using an extra file is probably what I will end up doing, and its definitely a cleaner solution, but I just though there might be a not entirely cumbersome way to "serialize" a sheet into VB code. Seems like there isn't.
Martin
@Martin: How do you ship your VBA code without exchanging the XLS file where your macro resides?
Doc Brown
Basically, the code is shipped along with the rest of the report config, so I can't add sheets there.
Martin
@Martin: I am confused, I thought you were talking about an Excel macro, a piece of VBA code embbeded into an Excel sheet. Are you talking of something different like a VBScript macro? Or is your report config an Excel document, where you just don't want to add sheets, because the users of the document must not see them? In this case, perhaps it is ok to add the template sheets as invisible pages to your config file.
Doc Brown