Need VBA Help! For join the numbers in-group separating by vertical bar.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

My result data range D10:I22 with 6 numbers in each row, this result I want to put in the 7 group of 7 numbers...1 to 7, 8 to 14, 15 to 21 and so on separating by the vertical bar in the range M6:S21 as shown in the data layout below and for the more detail information the image is attached.

Please need VBA help?

*ABCDEFGHIJKLMNOPQRSTU
1GR1GR2GR3GR4GR5GR6GR7
2181522293643
3291623303744
43101724313845
54111825323946
65121926334047
76132027344148
87142128354249
9Daten1n2n3n4n5n6SumJoinJoinJoinJoinJoinJoinJoin
1015-07-051018263541481781026344148
1118-09-09681230404113768123040|41
1213-09-121419202324281281419|2023|24|28
1315-06-1416132126401071|613212640
1412-04-1581519232733125815|1923|2733
1507-08-15226323740431802263237|4043
1625-11-15146742431031|4|6|74243
1703-04-18152329333741178152329|3337|41
1804-06-181142126354914611421263549
1909-09-184710182731974|710182731
2005-02-21314232935481523142329|3548
2109-05-2138192044451393819|2044|45
2215-07-2115171921323513918|17|19|2132|35
23
24
25
26

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • Join Number Seprating By Verticale Bar.png
    Join Number Seprating By Verticale Bar.png
    38.3 KB · Views: 8

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
How about
VBA Code:
Sub motilulla()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long
   
   Ary = Range("D10:I" & Range("D" & Rows.Count).End(xlUp).Row).Value2
   ReDim Nary(1 To UBound(Ary), 1 To 7)
   For r = 1 To UBound(Ary)
      For c = 1 To 7
         nc = Int((Ary(r, c) - 1) / 7) + 1
         If Nary(r, nc) = "" Then Nary(r, nc) = Ary(r, c) Else Nary(r, nc) = Nary(r, nc) & "|" & Ary(r, c)
      Next c
   Next r
   Range("M10").Resize(r - 1, 7).Value = Nary
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub motilulla()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nc As Long
  
   Ary = Range("D10:I" & Range("D" & Rows.Count).End(xlUp).Row).Value2
   ReDim Nary(1 To UBound(Ary), 1 To 7)
   For r = 1 To UBound(Ary)
      For c = 1 To 7
         nc = Int((Ary(r, c) - 1) / 7) + 1
         If Nary(r, nc) = "" Then Nary(r, nc) = Ary(r, c) Else Nary(r, nc) = Nary(r, nc) & "|" & Ary(r, c)
      Next c
   Next r
   Range("M10").Resize(r - 1, 7).Value = Nary
End Sub
Fluff, I like the macro it worked even without the header numbers in range M2:S8 result absently perfect, as I require. (y)

Thank you so much for your help and time you took for building a macro solution.

VBA Code:
Just a note after I run the code it stops at the line Below
"If Nary(r, nc) = "" Then"

After changing line "For c = 1 To 7"

To this "For c = 1 To 6" run normally

Good Luck have a good day

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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