combining rows(300 words) into 30 words each in separate cell

coolkris

New Member
Joined
Jun 10, 2019
Messages
3
Dear all,

I need to combine 300 words in a column (separate cells) in to 30 words in single cell each. I will have to do it many more times....
I use the forumula =concatenate(transpose(INDEX(A1:A1000,30*(row()-1)+1):INDEX(A1:A1000,30*(row()-1)+30))&" ") and drag it down.
Problem is I have to F9 remove { } and conotate again for all the rows.

I am looking for VBA/or forumula to short cut this.

Thanks

Krish

 

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.
I think this code will do what you are after (it outputs to Column B)...
Code:
Sub ThreeHundredToTenAtThirtyEach()
  Dim R As Long
  For R = 1 To 300 Step 30
    Cells((R + 29) / 30, "B") = Join(Application.Transpose(Cells(R, "A").Resize(30)))
  Next
End Sub
 
Last edited:
Upvote 0
thank you sir, I am glad that you are civil engineer also. I am a draftsman(tekla) from India. This works perfectly sir. But It is having spaces. Is there anyway we can add trim also in this.

Thanks

Krish
 
Upvote 0
But It is having spaces. Is there anyway we can add trim also in this.
I am not sure what you mean by this. Do you not want spaces between the words?

Or do you mean that some of your cells are blank and because of that you are getting multiple spaces instead of single spaces between words? If this is what you meant, then try this code...
Code:
Sub ThreeHundredToTenAtThirtyEach()
  Dim R As Long
  For R = 1 To 300 Step 30
    Cells((R + 29) / 30, "B") = Application.Trim(Join(Application.Transpose(Cells(R, "A").Resize(30))))
  Next
End Sub
 
Last edited:
Upvote 0
thank you so much sir, exactly this is what required.

This is the last one
I need to remove everything including second "-".

Like the part numbers combined with sheet numbers. MB-1-1/2 exactly text in red need to be removed wherever it is threre. The first "-" is ok (TB1-2)

th
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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