I have been using this code as a starting point: https://danwagner.co/how-to-transpose-horizontal-data-to-vertical-data-for-easy-pivot-tables/
One one of my cells Ax (x referring to the number), the content is ABCDEFGHI and I want to substring the cells every 2 characters, and the last set is 3 characters. Final result looks like:
AB CD EF GHI
At line 44, using the variable
varDetails = .Range(.Cells(lngIdx, 1), .Cells(lngIdx, 4))
and think that is where I need to modify the code. I am not fluent enough with VBA and need some help.
Mid()extracts substrings. If you have a problem in usingMid(), please explain what the problem is. The code snippet that you give lacks context (saying that it is at line 44 doesn't help us) and appears to have little to do with the rest of your question.varDetailscontains this string with 9 characters, then you can usMid()to extract the substrings that you want. It is an easy function to use: homeandlearn.org/excel_vba_mid_function.htmllngIdxto start at2but would rather have it start at 5, replace the 2 inFor lngIdx = 2 To lngLastRowby 5. That seems to address the issue in your comment. Not meaning to sound harsh, but if you want to use VBA then you should learn VBA. Making random changes to code that you find on the internet but don't understand isn't a reliable way to get code which does what you want.