VBA Merge cells using input box

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
525
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Hi Is it possible to merge cells together deliminated by an input box, Any help would be appreciated

Deliminators: " : ", ", ", " ", ",", ""

Example:

From This
ab
cd

<tbody>
</tbody>

To This

a : b : c : d

<tbody>
</tbody>

Or

a, b, c, d

<tbody>
</tbody>
Or

a b c d

<tbody>
</tbody>
Or

a,b,c,d

<tbody>
</tbody>
Or This

abcd

<tbody>
</tbody>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How about
Code:
Sub ConcatDelim()
   Dim Delim As String
   Dim Tmp As String
   Dim Cl As Range
   
   Delim = InputBox("Please enter deliminator")
   For Each Cl In Range("A1:B2")
      If Len(Tmp) = 0 Then
         Tmp = Cl.Value
      Else
         Tmp = Tmp & Delim & Cl.Value
      End If
   Next Cl
   Range("A1").Value = Tmp
End Sub
 
Upvote 0
Hi Fluff, This is Perfect as always. Thank you
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,265
Members
449,219
Latest member
daynle

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