On 2002-03-31 07:21, swaink wrote:
Hi There all,
sorry for the confusion Tom, Ret79 no i dont have the headers written down on a spread sheet, im trying to achieve it just using the macro, but I could do.
At the minute Ive just written them into a macro like this
Range("A1").Select
ActiveCell.FormulaR1C1 = "Date"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Time"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Name"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Location" etc
as you can see its rather long.
Kev
This message was edited by swaink on 2002-03-31 07:23
Just a suggestion...
I have found through experience that it is better to write the column headings on some dummy input spreadsheet and read them in from a macro rather than put the names directly into the macro. Although what you are doing works fine, it is very inconvenient to make any changes to it.
For instance, say you wanted to swap two column names around, correct spelling, or add an extra column name or whatever - you would have to change your macro everytime which for many reasons is a bad idea especially so if other people might want to use your macro. Also as you said, your current macro is very laborious to write, imagine if you had 100 or 250 column names?!
It was for this reason that I started to put colum headings in a column, on any old dummy sheet, then construct the macros I gave you to read off what you had in a column. As the macro recognises the column as a dynamic range, it will work whether you change column names around, add column names to the list, reduce the list or whatever - through experience I have found this makes it a better alternative as any changes are automatically picked up.
So my advice is, try and make these things general so that changes will be easily made.
Also, I have found that if there are inputs to the macro, they are best coming from a spreadsheet. In this way, if changes are to be made, you simply edit your inputs on a spreadsheet rather than having to edit them in the code everytime.
I hope I don't sound patronising, but I'm sure the more you will work with such things the more you will understand what I am going on about!
Good luck,
RET79
This message was edited by RET79 on 2002-03-31 08:49