ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 852
- Office Version
- 365
- 2019
- Platform
- Windows
Looking for the easiest way to combine two columns with a decimal. I have a file that has prices on it. But it comes to me with the prices all together without the decimal. Below is an example (1,000+ records) and it is a TXT file so when I convert it over to excel that is all in 1 cell. So I can convert it to the correct columns I desire but the prices just end up on their own columns (left of decimal in one column right of decimal in the other). I wasn't sure if can be handled via text to columns or do I really need to find a way to merge it somehow?
ST1AAAAAAA20240410XXXXXX000000002452530000END 00000000248991000020240409ABCD
4/10 Price should be 24.5253
4/09 Price should be 24.8991
Left side of space gap: There will always be 4 zeroes before the "END"
Right side of space gap: There will always be 4 zeroes before the prior day's date
Thanks in advance for looking at this.
ST1AAAAAAA20240410XXXXXX000000002452530000END 00000000248991000020240409ABCD
4/10 Price should be 24.5253
4/09 Price should be 24.8991
Left side of space gap: There will always be 4 zeroes before the "END"
Right side of space gap: There will always be 4 zeroes before the prior day's date
VBA Code:
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(2, 2), Array(11, 1), Array(19, 1), Array(25, 1), _
Array(35, 1), Array(39, 1), Array(43, 1), Array(56, 1), Array(78, 1), Array(82, 1), Array( _
86, 1), Array(94, 2)), TrailingMinusNumbers:=True
.Columns("A:L").AutoFit
Thanks in advance for looking at this.