S.H.A.D.O.
Well-known Member
- Joined
- Sep 6, 2005
- Messages
- 1,915
Good afternoon,
I have a macro that outputs number data into columns "A:G", just as a General format.
Now there could be data in all of the columns, or 3 of the columns, or 4 of the columns etc
I have a line of code that concatenates these columns...
...which works perfectly.
At the moment, further down in the Macro I have a line of code...
...that formats the Concatenated cells according to the number of columns that has data. In this case the code above would format it as 3, being "000", meaning there are 3 columns with data in. This has to be changed manually within the code each time according to the number of columns used.
My question is, is there a way that I can amend the first line of code I have posted to accomodate this as the data is output from the Macro please. So for 4 columns it automatically formats the Concatenated cells as "0000", for 5 columns it automatically formats the Concatenated cells as "00000" etc So basically it is only formated according to the number of columns used and not for columns that have no data.
Thanks in advance.
I have a macro that outputs number data into columns "A:G", just as a General format.
Now there could be data in all of the columns, or 3 of the columns, or 4 of the columns etc
I have a line of code that concatenates these columns...
Code:
Range("I1:I" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=A1&B1&C1&D1&E1&F1&G1"
...which works perfectly.
At the moment, further down in the Macro I have a line of code...
Code:
Range("I1:I" & Range("A" & Rows.Count).End(xlUp).Row).NumberFormat = "000"
...that formats the Concatenated cells according to the number of columns that has data. In this case the code above would format it as 3, being "000", meaning there are 3 columns with data in. This has to be changed manually within the code each time according to the number of columns used.
My question is, is there a way that I can amend the first line of code I have posted to accomodate this as the data is output from the Macro please. So for 4 columns it automatically formats the Concatenated cells as "0000", for 5 columns it automatically formats the Concatenated cells as "00000" etc So basically it is only formated according to the number of columns used and not for columns that have no data.
Thanks in advance.