Need help Arranging/Filtering Data

desibouy

Board Regular
Joined
Nov 20, 2014
Messages
98
Office Version
  1. 365
Platform
  1. Windows
Hey,

So we're using a new system (shopify) and I've been struggling with Data Imports for a while now. Reason because Shopify uses Variant Products (Size Color etc), So the Parent Item (the one where the Variants are stored under) needs to be labelled "Top Row" in a separate Column (usually I don't use this) Shopify then uses this along with Handle to import the Data.

I have created many files and each one has pretty much failed. I've tried using filters but they don't work so having to manually fix these.

This is an example of the issue
Incontinence Category_UPDATED2022_TP.xlsx
ABCDE
1Variant Metafield: Unique-Internal-ID.Unique_Internal_ID [string]Variant Metafield: Product-Family-ID.Product_Family_ID [string]HandleTitleTop Row
28265082644Attends_Extended_Wear_Brief
38264982644Attends_Extended_Wear_Brief
48264882644Attends_Extended_Wear_Brief
58264782644Attends_Extended_Wear_Brief
68264682644Attends_Extended_Wear_BriefAttends Extended Wear BriefTRUE
78264582644Attends_Extended_Wear_Brief
816591655Cardinal_Protective_UnderwearCardinal Protective UnderwearTRUE
916581655Cardinal_Protective_Underwear
1016561655Cardinal_Protective_Underwear
1122162207Nu-Fit_Briefs
1222152207Nu-Fit_Briefs
1322132207Nu-Fit_Briefs
1422122207Nu-Fit_BriefsNu-Fit BriefsTRUE
1522112207Nu-Fit_Briefs
1622312222Prevail_Breezers_Adult_Briefs
1722302222Prevail_Breezers_Adult_Briefs
1822292222Prevail_Breezers_Adult_Briefs
1922282222Prevail_Breezers_Adult_Briefs
2022272222Prevail_Breezers_Adult_BriefsPrevail Breezers Adult BriefsTRUE
2122262222Prevail_Breezers_Adult_Briefs
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D1Cell ValueduplicatestextNO



and this is what I'm trying to achieve.
Incontinence Category_UPDATED2022_TP.xlsx
ABCDE
1Variant Metafield: Unique-Internal-ID.Unique_Internal_ID [string]Variant Metafield: Product-Family-ID.Product_Family_ID [string]HandleTitleTop Row
28265082644Attends_Extended_Wear_BriefAttends Extended Wear BriefTRUE
38264982644Attends_Extended_Wear_Brief
48264882644Attends_Extended_Wear_Brief
58264782644Attends_Extended_Wear_Brief
68264682644Attends_Extended_Wear_Brief
78264582644Attends_Extended_Wear_Brief
816591655Cardinal_Protective_UnderwearCardinal Protective UnderwearTRUE
916581655Cardinal_Protective_Underwear
1016561655Cardinal_Protective_Underwear
1122162207Nu-Fit_BriefsNu-Fit BriefsTRUE
1222152207Nu-Fit_Briefs
1322132207Nu-Fit_Briefs
1422122207Nu-Fit_Briefs
1522112207Nu-Fit_Briefs
1622312222Prevail_Breezers_Adult_BriefsPrevail Breezers Adult BriefsTRUE
1722302222Prevail_Breezers_Adult_Briefs
1822292222Prevail_Breezers_Adult_Briefs
1922282222Prevail_Breezers_Adult_Briefs
2022272222Prevail_Breezers_Adult_Briefs
2122262222Prevail_Breezers_Adult_Briefs
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D1Cell ValueduplicatestextNO


Again I've tried using filters and custom sort but I'm not getting anywhere :(
As long as the title appears in the first row then It will work, but as you can see the titles are appearing further down.

Please can someone help me out please?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
See if this does what you want. Test with a copy of your data as it over-writes the existing values in columns D:E.

VBA Code:
Sub MoveToTop()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
  
  a = Range("C1", Range("C" & Rows.Count).End(xlUp)).Resize(, 3).Value
  ReDim b(1 To UBound(a) - 1, 1 To 2)
  For i = UBound(a) To 2 Step -1
    If Len(a(i, 2)) > 0 Then k = i
    If a(i, 1) <> a(i - 1, 1) Then b(i - 1, 1) = a(k, 2): b(i - 1, 2) = a(k, 3)
  Next i
  Range("D2:E2").Resize(UBound(b)).Value = b
End Sub
 
Upvote 0
Solution
See if this does what you want. Test with a copy of your data as it over-writes the existing values in columns D:E.

VBA Code:
Sub MoveToTop()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
 
  a = Range("C1", Range("C" & Rows.Count).End(xlUp)).Resize(, 3).Value
  ReDim b(1 To UBound(a) - 1, 1 To 2)
  For i = UBound(a) To 2 Step -1
    If Len(a(i, 2)) > 0 Then k = i
    If a(i, 1) <> a(i - 1, 1) Then b(i - 1, 1) = a(k, 2): b(i - 1, 2) = a(k, 3)
  Next i
  Range("D2:E2").Resize(UBound(b)).Value = b
End Sub

Hi Peter,

Thanks for reply.

I've just tried this but it doesn't work. I'm getting 'Mismatch' error. This code being highlighted Yellow.

VBA Code:
 If a(i, 1) <> a(i - 1, 1) Then


Just to clarify, you said it will replace Columns D:E, however I don't usually use Column E (Top Row) I've left it in my example as a way to distinguish how it should be.
I'll try and explain again, probably my fault but the variants for some reason appear further down the file. Shopify uses Handle and Title to add, replace and merge other columns. So let's say I want to update the products price, I need Handle and Title in all my spreadsheets but because I've filtered over and over again either to sort out categories, products names, and other such thing, my products are not in any order so when I import, Shopify says wait, the same handle or title appears further down the sheet. So this what I'm after, a way to regroup those products no matter how many times I change the sorting. in our old system, we used Unique ID and Product Family ID, I've been trying to use this to, to help with sorting.

I hope that clarifies. Sorry for the confusion.
 
Upvote 0
Glad you have it resolved. Thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

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