Column Change

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 this data and not sure if there is a way to get the output.

eg:- Row no 3 have a name and with respect to row 4 the nex 5 rows has its left and right, so in single line with respect ot row 3 ti will have data for 4 and 5.
so in singel ine row 3 will have its all detils,

I tried differnt ways but no help any way to fix it a vba will do.


I am confused how to explain it but I hope this table will give the right view.




Book1
BCDEFGH
1
2Output
3Bundle-Ether10 Gi101/0/0/4 Local Configured 0x8000 Gi102/0/0/4 Local Active 0x8000
4 Gi101/0/0/4 Local Configured 0x8000 0x0000 1000000
5 Gi102/0/0/4 Local Active 0x8000 0x0000 1000000
6Bundle-Ether20 Gi100/0/0/5 Local Configured 0x8000 Gi101/0/0/5 Local Configured 0x8000
7 Gi100/0/0/5 Local Configured 0x8000 0x0000 1000000
8 Gi101/0/0/5 Local Configured 0x8000 0x0000 1000000
9Bundle-Ether1001
10 Te0/2/0/28 Local Active 0x8000 0x0000 10000000 Te0/2/0/28 Local Active 0x8000 Te0/2/0/29 Local Active 0x8000 Te0/3/0/28 Local Active 0x8000 Te0/3/0/29 Local Active 0x8000
11 Te0/2/0/29 Local Active 0x8000 0x0000 10000000
12 Te0/3/0/28 Local Active 0x8000 0x0000 10000000
13 Te0/3/0/29 Local Active 0x8000 0x0000 10000000
14Bundle-Ether1002 Te0/2/0/38 Local Active 0x8000 Te0/2/0/39 Local Active 0x8000 Te0/3/0/38 Local Active 0x8000 Te0/3/0/39 Local Active 0x8000
15 Te0/2/0/38 Local Active 0x8000 0x0000 10000000
16 Te0/2/0/39 Local Active 0x8000 0x0000 10000000
17 Te0/3/0/38 Local Active 0x8000 0x0000 10000000
18 Te0/3/0/39 Local Active 0x8000 0x0000 10000000
Sheet1
 
Once I run it its givne me this not sure why.

1701941079609.png
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Just noticed you have a space at the start of the text in the cells so it was producing a blank as an answer in the code, below corrects it and removes the spaces.


Two options as the above post shows data in column A as well...
  • Option 1 - this will clear the data from column A when clearing data in columns B and C
  • Option 2 - this will leave the data in column A and only clear data in column B and C

Option 1...
VBA Code:
Sub MoveStuffOpt1()

Dim MatchRow As Integer
Dim MoveOffset As Integer
Dim ColLetter As String
Dim CelText As String
Dim Frow As Integer
Dim Lrow As Integer
Dim n As Long

Frow = 3        '<<< Change this number depending on the row your data starts in
ColLetter = "E" '<<< Change this letter to the column you want to start adding the data in to

Lrow = Range("B" & Frow).End(xlDown).Row 'sets the last row in the data assuming there are no gaps in the data
MoveOffset = 0

For Each i In Range("B" & Frow & ":B" & Lrow)
    If i.Value Like "Bundle*" Then
    MatchRow = i.Row
    MoveOffset = 0
    Else
        n = InStr(CelText, "Local") - 1
        Range(ColLetter & MatchRow).Offset(0, MoveOffset).Value = Left(CelText, n)
        MoveOffset = MoveOffset + 1
        i.EntireRow.ClearContents
    End If
Next i

End Sub

Option 2...
VBA Code:
Sub MoveStuffOpt2()

Dim MatchRow As Integer
Dim MoveOffset As Integer
Dim ColLetter As String
Dim CelText As String
Dim Frow As Integer
Dim Lrow As Integer
Dim n As Long

Frow = 3        '<<< Change this number depending on the row your data starts in
ColLetter = "E" '<<< Change this letter to the column you want to start adding the data in to

Lrow = Range("B" & Frow).End(xlDown).Row 'sets the last row in the data assuming there are no gaps in the data
MoveOffset = 0

For Each i In Range("B" & Frow & ":B" & Lrow)
    If i.Value Like "Bundle*" Then
    MatchRow = i.Row
    MoveOffset = 0
    Else
        CelText = Trim(Replace(i.Value, " ", ""))
        n = InStr(CelText, "Local") - 1
        Range(ColLetter & MatchRow).Offset(0, MoveOffset).Value = Left(CelText, n)
        MoveOffset = MoveOffset + 1
        i.Resize(1, 2).ClearContents
    End If
Next i

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,712
Messages
6,174,033
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