help needed -- link data in 1 cell

rainx

Board Regular
Joined
Jul 4, 2008
Messages
210
Sample data:
<table x:str="" style="border-collapse: collapse; width: 189pt;" width="252" border="0" cellpadding="0" cellspacing="0"><col style="width: 90pt;" width="120"> <col style="width: 99pt;" width="132"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl62" style="height: 15pt; width: 90pt;" width="120" height="20">Machine</td> <td class="xl63" style="width: 99pt;" width="132">Part Number</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 1</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">123</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 2</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">123</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 3</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">123</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 1</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">123</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 2</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">456</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 1</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">456</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl64" style="height: 14.25pt; width: 90pt;" width="120" height="19">machine 3</td> <td class="xl65" style="width: 99pt;" x:num="" width="132" align="right">456</td> </tr> </tbody></table>
Hi everyone, I have this problem here, that i need to based on tis sample data come out with sth like tt:

<table x:str="" style="border-collapse: collapse; width: 326pt;" width="434" border="0" cellpadding="0" cellspacing="0"><col style="width: 90pt;" width="120"> <col style="width: 236pt;" width="314"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl62" style="height: 12.75pt; width: 90pt;" width="120" height="17">
</td> <td class="xl62" style="width: 236pt;" width="314">Used In:</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl62" style="height: 12.75pt;" x:num="" height="17">123</td> <td class="xl62">Machine 1, Machine 2, Machine 3</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl62" style="height: 12.75pt;" x:num="" height="17">456</td> <td class="xl62">Machine 2, Machine 1, Machine 3</td> </tr> </tbody></table>

I need to group those machines under 1 part number. For instance, part 123 is used in which machines, I need to state them in a way like above. But repeated should not be stated again.

Hope someone is able to help.

Thanks alot in advance!
 
I tried this:


Sheets("sheet2").Range("a1").Resize(n, 2).Value = b</pre>
But there is an application defined or object defined error...

THanks!
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
try
Rich (BB code):
Sub test()
Dim a, b(), i As Long, n As Long, temp As String, e
With Sheets("YourSheetNameWithDataHere")
    a = .Range("a1" .Range("a" & Rows.Count).End(xlUp)).Resize(,2).Value
    ' where a1 has heading, change to suite
End With
ReDim b(1 To UBound(a,1), 1 To 2)
With CreateObject("Scripting.Dictionary")
    .CompareMode = vbTextCompare
    For i = 2 To UBound(a,1)
        If Not .exists(a(i,2)) Then
            n = n + 1 : b(n,1) = a(i,2) : .add a(i,2), n
        End If
        b(.item(a(i,2)), 2) = b(.item(a(i,2)), 2) & _
                IIf(b(.item(a(i,2)), 2) <> "", ",", "") & a(i,1)
    Next
    .removeall
    For i = 1 To n
        For Each e In Split(b(i,2),",")
            If Not .exists(e) Then
                temp = temp & "," & e
                .add e, Nothing
            End If
        Next
        b(i,2) = Mid$(temp,2)
        temp = "" : .removeall
    Next
End With
Sheets("DestinationSheetNameHere").Range("a1").Resize(n,2).Value = b
End Sub
 
Upvote 0
a = .Range("a1" .Range("a" & Rows.Count).End(xlUp)).Resize(,2).Value

this come out in red.. dunno why..

thanks!
 
Upvote 0
Missed a comma ","
Rich (BB code):
a = .Range("a1", .Range("a" & Rows.Count).End(xlUp)).Resize(,2).Value
 
Upvote 0
I change to tis

a = Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 2).Value

is that right?

Thanks!
 
Upvote 0
Sheets("Sheet1").Range("a1").Resize(n, 2).Value = b

I still have an error with this line.. application defined or object...

Thanks!
 
Upvote 0
If that happens, most probably, setting range of a is not correct.
Can you tell me exact address of your dara range ?
 
Upvote 0
er, but when i tried changing to sheet 2 instead of sheet 1 den it works le?
whats the issue with sheet 1 ar?

Thanks!
 
Upvote 0
Sheets("Sheet1").Range("a1").Resize(n, 2).Value = b

I still have an error with this line.. application defined or object...

Thanks!
Well if the error saying "Out of subscript", then your sheet name is incorrect, but object difined error....

No idea...
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,813
Members
449,469
Latest member
Kingwi11y

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