Optimal Join of a text to string with Logic

sryair

New Member
Joined
Feb 5, 2016
Messages
7
I need to Join together By Logic some Attributes (Delimited with “ | “


SHORT NAME: MODULE,DISCRETE
TYPE: OUTPUT
SIZE: 100MM
POWER SUPPLY: 24VDC
POWER RATING: 100W
NUMBER OF INPUTS: 16 DIGITAL
NUMBER OF OUTPUTS: 16 ANALOG
MOUNTING: PLUG-IN
APPLICATION: COMPUTER
FREQUENCY: 50HZ

The max length of the join string is 50 characters
The first two attributes must be in the join string

The Other Attributes by the Sequence

Then required to optimize and check if the join length of the string is the max possible

the string look like:MODULE,DISCRETE | OUTPUT | 100MM | ETC....

Any ideas how to do this with VBA code in Excel?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Code:
Sub sryair()For Each cell In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
 t = InStr(1, cell.Value, ": ") + 2
 txt = Mid(cell.Value, t, Len(cell.Value) - t)
 If tmp = "" Then
 tmp = txt
 Else
 tmp = tmp & "|" & txt
 End If
Next cell
tmp = Left(tmp, 50)
MsgBox tmp
End Sub
 
Upvote 0
Thank you for your comment

should connect the text values in column "B"
The rules are:
the maximum length of the join string 50
Do not cut any value during the optimization (ie, the value appears or does not appear)
If a certain value is too long is required to check if you can connect the following value
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,697
Members
449,117
Latest member
Aaagu

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