I have a macro, where I convert text into columns, so that I can use the data from my PDF file.
Althought it works really well, I would like to know if it could be developed.
My data should look something like this:
Invoice 10-12-2017 USD 400,00
Creditmemo 18-12-2017 USD 205,60
Invoice 27-12-2017 USD 906,75
Invoice 29-12,2017 USD 855,00
Interest I12391 31-12-2017 USD 105
As you might notice from the above, the "Interest" line has an additional number, which prevents the data from being aligned correctly.
I want it to look more like this:
[Invoice] 10-12-2017 USD 400,00
[Creditmemo] 18-12-2017 USD 205,60
[Invoice] 27-12-2017 USD 906,75
[Invoice] 29-12,2017 USD 855,00
[Interest I12391] 31-12-2017 USD 105
What I have so far:
My code is this atm:
rng1 = Range("A3:A750")
Range(rng1).TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1)), TrailingMinusNumbers:=True
Goal:
I want the code to loop through my data, whenever it finds "Interest" it should copy the number and insert it after "Interest". Instead of being two different cells they should merge, and become one as "Interest I12391". Then the data will be alligned correctly, since the "Interest" row has one additional row, than the others
Should I do a .Find.Address on "Interest", and reuse the formula with a .Offset(0,1) and merge those two? Or is there a simpler and more efficient way to do so?
Other than the main question... Is it possible for me to use Range.TextToColums, so it only affects the worksheet I need it to, and not the entire workbook?