Help with VBA code printing data with an offset

peter_z

Board Regular
Joined
Feb 27, 2011
Messages
87
Hey Guys,

I have some code which is seperating some clumped data by "|" pulling back some individual pieces of string. Just wondering how would I print these individual pieces of string into the same row but a different column until there is no more info?

So far I have come up with:

Code:
 Sub SplitDemo()
    Dim txt As String
    Dim x As Variant
    Dim c As Variant
    Dim i As Long
    Dim ii As Long
    
       ' This code is seperating the clumped data
        txt = Worksheets("RAW_DATA").Range("E2")
        x = Split(txt, "|")
    
        For i = 0 To UBound(x)
           Debug.Print x(i)
      
        Next i
    
   '  This is me struggling to get it printed into the workbook 
    For ii = 2 To UBound(c)
    x(i) = Worksheets("RAW_DATA").Range.Offset(0, 5 + ii)
Next ii
       
End Sub

Thanks very much for your help :)
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Instead of looping, you can transpose the array onto the worksheet.

Code:
Sub SplitDemo()
    Dim txt As String
    Dim x As Variant
    Dim c As Variant
    Dim i As Long
    Dim ii As Long
 
       ' This code is seperating the clumped data
        txt = Worksheets("RAW_DATA").Range("E2")
        x = Split(txt, "|")
 
        For i = 0 To UBound(x)
           Debug.Print x(i)
        Next i
 
        Range("F2").Resize(1, UBound(x)+1) = WorksheetFunction.Transpose(WorksheetFunction.Transpose(x))
End Sub

Denis
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

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