Lefemmenikita
Board Regular
- Joined
- Jan 28, 2014
- Messages
- 59
- Office Version
- 2013
- Platform
- Windows
HI
I am exporting a 6 digit number from a system into Excel. When this is pasted into excel, this is reformatted as a number instead of being left as a text value.
Column A with the code shows what the reformatted number looks like. Column B shows what I want it to look like.
This is ok when the range of the reformatted cells remains the same and/or I am able to use a helper column like column B to insert a formula.
However, the reformatted numbers are not always in the same place and I am not always able to insert another column to insert a formula.
What I was wanting was a macro which allows me to reformat only the selected active cells.
e.g. If I select cell A4, I want VBA to insert a formula similar to =REPT(0,6-LEN(activecell.value))&Activecell.value
I have seen this done with 'round' formulas though I don't know how to adapt this to my current requirements.
Thanks
I am exporting a 6 digit number from a system into Excel. When this is pasted into excel, this is reformatted as a number instead of being left as a text value.
Column A with the code shows what the reformatted number looks like. Column B shows what I want it to look like.
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B5 | B2 | =REPT(0,6-LEN(A2))&A2 |
This is ok when the range of the reformatted cells remains the same and/or I am able to use a helper column like column B to insert a formula.
However, the reformatted numbers are not always in the same place and I am not always able to insert another column to insert a formula.
What I was wanting was a macro which allows me to reformat only the selected active cells.
e.g. If I select cell A4, I want VBA to insert a formula similar to =REPT(0,6-LEN(activecell.value))&Activecell.value
I have seen this done with 'round' formulas though I don't know how to adapt this to my current requirements.
Thanks