Hi, I found a macro that will combine cells that I highlight but separate them with a space, two || symbols, and another space. The cells being combined are simply a set of numbers in a 4 digit format. So for example, if I will highlight cells J2:J4 which contain 3 different numbers and then run the macro while those are selected, the result populates in K2 and it will look like: 0943 || 0026 || 0075 ||.
The code I found and used is:
Sub combineLMnumbers()
Dim rng As Range
Dim i As String
For Each rng In Selection
i = i & rng & " || "
Next rng
Range("K2").Value = Trim(i)
End Sub
This is great, but I am looking for a slight alteration for it to not have that space and symbols after the last number so that it would instead read 0943 || 0026 || 0075
If it helps any, in the code where I have " || ", that originally was just " " and I changed to to the " || " as that suits the purpose I need it for. Is there a simple adjustment that can be made to the above code to allow for the result I am looking for where it doesn't put the || symbols after the last number?
Bookmarks