Delimit Every 23rd Row -Can't get macro to Loop properly

Tash Point O

New Member
Joined
Feb 12, 2018
Messages
47
Hello, Below is the macro I made to delimit data, I need it to Loop every 23rd row until 23rd row = "". However 1 of 2 things happens: The second set of data past range A2 delimits and moves all Data to Column B or the looping stops at the second set of data and it says there is no data to parse. I took the loop out of the code below but it was a do until activecell = "". Obvs I'm doing something wrong but I can't pinpoint it :mad:
10o0939.jpg
[/IMG]

Here is what the data looks like unformatted:
15zgoqh.jpg


And after I run my Macro:
257j72d.jpg
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
First, in future, please post your code as text and wrap them around code tags. This enables the volunteers here to simply copy and paste the code. Otherwise they wouldn't be able to do so with images.

Secondly, your row offset should be 22, not 23. Try the following...

Code:
Sub Test_New_Delimiter_Transpose()    
    Dim CompDeals As Range
    
    Set CompDeals = Range("A2")
        
    While (Len(CompDeals) > 0)
        CompDeals.TextToColumns Destination:=CompDeals.Offset(, 1), . . .
        CompDeals.ClearContents
        Set CompDeals = CompDeals.Offset(22, 0)
    Wend
        
End Sub

However, depending on the size of your data, the following may or may not be a bit more efficient...

Code:
Sub Test_New_Delimiter_Transpose()

    Dim i As Long
    Dim LastRow As Long
    
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = 2 To LastRow Step 22
        Cells(i, "A").TextToColumns Destination:=Cells(i, "B"), . . .
        Cells(i, "A").ClearContents
    Next i
    
End Sub
 
Upvote 0
First, in future, please post your code as text and wrap them around code tags. This enables the volunteers here to simply copy and paste the code. Otherwise they wouldn't be able to do so with images.

Secondly, your row offset should be 22, not 23. Try the following...


However, depending on the size of your data, the following may or may not be a bit more efficient...

Code:
Sub Test_New_Delimiter_Transpose()

    Dim i As Long
    Dim LastRow As Long
    
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = 2 To LastRow Step 22
        Cells(i, "A").TextToColumns Destination:=Cells(i, "B"), . . .
        Cells(i, "A").ClearContents
    Next i
    
End Sub

Dom,

Thank you for pointing out my error in image posting, I thought it looked horrid and I will do as you suggested next time for sure.

Your second code (which was concluded as more efficient) worked like a charm. Thank you very much, I really appreciate your time.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top