CONCATENATE

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,132
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have the code and is all perfect on if the data is in col e and f, bus as per the table the data will start for E and end to AA, so ned to modify the code to get the right output

Book2
BCDEFGHIJ
1Actual Bundle EtherOutPut
2BE10Gi101/0/0/4 ; Gi102/0/0/4 Gi101/0/0/4 Local Configured 0x8000 Gi102/0/0/4 Local Active 0x8000
3BE40Gi101/0/0/13 Gi101/0/0/13 Local Active 0x8000
4BE50Te0/2/0/3 ; Te0/3/0/3 Te0/2/0/3 Local Active 0x8000 Te0/3/0/3 Local Active 0x8000
5BE101Te0/3/0/9 Te0/3/0/9 Local Active 0x8000
6BE110Gi100/0/0/25 ; Gi101/0/0/25 Gi100/0/0/25 Local Active 0x8000 Gi101/0/0/25 Local Active 0x8000
7BE120Gi100/0/0/24 ; Gi101/0/0/24 Gi100/0/0/24 Local Active 0x8000 Gi101/0/0/24 Local Active 0x8000
8BE130Gi100/0/0/27 Gi100/0/0/27 Local Active 0x8000
9BE1000Te0/2/0/18 ; Te0/2/0/19 ; Te0/3/0/18 ; Te0/3/0/19 Te0/2/0/18 Local Active 0x8000 Te0/2/0/19 Local Active 0x8000 Te0/3/0/18 Local Active 0x8000 Te0/3/0/19 Local Active 0x8000
10BE10Te0/0/0/6 ; Te0/1/0/6 Te0/0/0/6 Local Active 0x8000 Te0/1/0/6 Local Active 0x8000
11BE20Te0/0/0/5 ; Te0/1/0/5 Te0/0/0/5 Local Active 0x8000 Te0/1/0/5 Local Standby 0x8000
12BE40Te0/0/0/12 ; Te0/0/1/4 ; Te0/1/0/12 ; Te0/1/1/4 Te0/0/0/12 Local Active 0x8000 Te0/0/1/4 Local Active 0x8000 Te0/1/0/12 Local Active 0x8000 Te0/1/1/4 Local Active 0x8000
13BE500Te0/0/0/11 ; Te0/1/0/11 ; Te0/2/0/3 ; Te0/2/0/11 ; Te0/3/0/3 ; Te0/3/0/11 Te0/0/0/11 Local Active 0x8000 Te0/1/0/11 Local Active 0x8000 Te0/2/0/3 Local Active 0x8000 Te0/2/0/11 Local Active 0x8000 Te0/3/0/3 Local Active 0x8000 Te0/3/0/11 Local Active 0x8000
Sheet1




It works only for E and F columns, need to en till the last non blank cells in column B
VBA Code:
Sub ExtractAndCombineperfect()


    ' Get values from E2 and F2
    Dim valueE As String
    Dim valueF As String

    valueE = Range("E2").Value
    valueF = Range("F2").Value

    ' Take the first 14 characters from each value
    Dim truncatedValueE As String
    Dim truncatedValueF As String

    truncatedValueE = Left(valueE, 14)
    truncatedValueF = Left(valueF, 14)

    ' Combine truncated values with a semicolon and put the result in G2
    Range("D2").Value = Application.WorksheetFunction.Trim(truncatedValueE & ";" & truncatedValueF)
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
In that case you copied the data incorrectly, as it does not work on the OP's data, it has the same problem as RobP's original code.
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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