I m creating a template that users will be using for data entry. The worksheet (There will be only one) has to have very specific column headings due to constraints of further processing being done to the file by a separate application. Because these demands are so specific I am writing some data cleansing steps that correct common errors. First of them is simple forcing the column headers to be what they need to be.
To do this I have created a macro that runs before save. So that when they save the file common errors are corrected.
The problem I am having is that if the file is saved, then additional data is entered, or even if its not, but the file is subsequently saved, the headers are rewritten and not always in the first row of the sheet.
The code I am using seems pretty straight forward:
Range("A1").Value = "Header1"
Range("B1").Value = "Header2"
Range("C1").Value = "Header3"
Range("D1").Value = "Header4"
Range("E1").Value = "Header5"
Range("F1").Value = "Header6"
Range("G1").Value = "Header7"
Range("H1").Value = "Header8"
Range("I1").Value = "Header9"
Range("J1").Value = "Header10"
Range("K1").Value = "Header11"
Range("L1").Value = "Header12"
The first time the file is saved and the event is triggered the headers insert properly. Subsequent saves of the file throws them usually into unpredictable locations.
To do this I have created a macro that runs before save. So that when they save the file common errors are corrected.
The problem I am having is that if the file is saved, then additional data is entered, or even if its not, but the file is subsequently saved, the headers are rewritten and not always in the first row of the sheet.
The code I am using seems pretty straight forward:
Range("A1").Value = "Header1"
Range("B1").Value = "Header2"
Range("C1").Value = "Header3"
Range("D1").Value = "Header4"
Range("E1").Value = "Header5"
Range("F1").Value = "Header6"
Range("G1").Value = "Header7"
Range("H1").Value = "Header8"
Range("I1").Value = "Header9"
Range("J1").Value = "Header10"
Range("K1").Value = "Header11"
Range("L1").Value = "Header12"
The first time the file is saved and the event is triggered the headers insert properly. Subsequent saves of the file throws them usually into unpredictable locations.