Create Table with cells that contain data in another row for master sheet

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
582
Office Version
  1. 365
DATA_SHEET
ROWCOLUMN BCOLUMN ICOLUMN SCOLUMN TCOLUMN UCOLUMN VCOLUMN WCOLUMN X
1EANPRODUCT_IDBRAND_NAMEPACK_QTYPACK_TYPEPRODUCT_WEIGHTHEIGHTWIDTH
2550055005500512345ABCDE1SACHET500g100mm50mm
3662255336626468916FGHIJ5SACHET1000g250mm85mm
4965612669444452633IMJKK250g2033

PUBLISH SHEET

ROWCOLUMN ACOLUMN CCOLUMN DCOLUMN ECOLUMN FCOLUMN GCOLUMN H
1ATT_1ATT_2ATT_3ATT_4ATT_5ATT_6ATT_7
212345BRAND_NAMEPRODUCT_WEIGHT
368916BRAND_NAMEPACK_QTYPACK_TYPE
452633BRAND_NAMEPRODUCT_WEIGHTHEIGHTWIDTH
5

END RESULT
ROWCOLUMN BCOLUMN ICOLUMN SCOLLUMN TCOLUMN UCOLUMN VCOLUMN WCOLUMN X
1EANPRODUCT_IDBRAND_NAMEPACK_QTYPACK_TYPEPRODUCT_WEIGHTHEIGHTWIDTH
2550055005500512345ABCDE500g
3662255336626468916FGHIJ1SACHET
4965612669444452633IMJKKK250g2033


OK... A tad complicated to explain I think, but

In "Data Sheet" is the initial Data
In "Publish Sheet" is the data I need to publish based on the EAN/PRODUCT ID (In the row) and what columns I need to capture
In "End Result" is the data I need to come across (needs to be in the exact table format as "Data Sheet" omitting any data in cells that are not in the "Publish SHeet" tab

Data_Sheet = There are Column S to Column AEI with potential data in. Up to row 6064 in the Data_Sheet

Publish SHeet - Columns C to Column AD (Rows 2 to 227) have potential matches in (Some rows may only have 1 or 2 to be published, others could have 50)
 

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.
In the sheet "End Result" should be 5, correct?

1635795898719.png
 
Upvote 0
If the structure of your data is like your examples, then try the following:

VBA Code:
Sub CreateTable()
  Dim shD As Worksheet, shP As Worksheet, shR As Worksheet
  Dim c As Range, f As Range
  Dim j As Long, k As Long, m As Long, r As Long
  Dim v As Variant
  Application.ScreenUpdating = False
  Set shD = Sheets("Data")      'Set the name of your sheets
  Set shP = Sheets("Publish")
  Set shR = Sheets("Result")
  
  k = 1
  For Each c In shD.Range("I2", shD.Range("I" & Rows.Count).End(3))
    Set f = shP.Range("A:A").Find(c.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      r = f.Row
      k = k + 1
      shR.Cells(k, "B").Value = shD.Range("B" & c.Row).Value
      shR.Cells(k, "I").Value = c.Value
      
      For j = 3 To shP.Cells(r, Columns.Count).End(1).Column
        Set f = shD.Rows(1).Find(shP.Cells(r, j).Value, , xlValues, xlWhole, , , False)
        If Not f Is Nothing Then
          v = shD.Cells(r, f.Column).Value
          Set f = shR.Rows(1).Find(shP.Cells(r, j).Value, , xlValues, xlWhole, , , False)
          If Not f Is Nothing Then shR.Cells(k, f.Column).Value = v
        End If
      Next
    End If
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,331
Messages
6,124,311
Members
449,152
Latest member
PressEscape

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