magemaester
New Member
- Joined
- Dec 17, 2017
- Messages
- 10
Hi forum,
I have this piece of code which creates a dynamic array, redims it, then assigns a range of cells on a worksheet into it. The data that I populate into the array are ID's of people, that are formatted as TEXT with leading 0's. (e.g. "000123123", "000111223", "000199382".....)
However, when the values are pasted into Column B, all the leading "0"s disappear and the output is formatted as numbers. Does anyone know why that is happening/solution?
Many thanks.
I have this piece of code which creates a dynamic array, redims it, then assigns a range of cells on a worksheet into it. The data that I populate into the array are ID's of people, that are formatted as TEXT with leading 0's. (e.g. "000123123", "000111223", "000199382".....)
Code:
[COLOR=#006400]'Creates array[/COLOR]
Dim Array() as Variant
ReDim Array (1 to 1000, 1)
[COLOR=#006400]'Populates array with TEXT from Column A[/COLOR]
Array = Range("A1:A1000").Value
[COLOR=#006400]'Pastes data from array into Column B[/COLOR]
Range("B1:B1000").Value = Array
However, when the values are pasted into Column B, all the leading "0"s disappear and the output is formatted as numbers. Does anyone know why that is happening/solution?
Many thanks.