Aperras7
New Member
- Joined
- May 22, 2014
- Messages
- 36
Hi all,
I'm using a really simple macro to sort some cata in a table and I'm experiencing some trouble.
The first row of my column is an if formula that reference me a data depending on if the product is required or not. That the main reason why I used a Macro to sort them since everytime the "required" information changes, a new name might appear at the bottom of the list.
Here's the formula : =IFERROR(IF(INGREDIENTS!Q207="P2 - Soft Spec";INGREDIENTS!A207;"");"")
And here's the super basic VBA i'm using :
Sub Sort_P2s()
'
' Sort_P2s Macro
'
ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort.SortFields. _
Add Key:=Range("Tableau3[[#All],[Products]]"), SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
This works fine to sort my datas in the first row, but everything else in the table doesn't follow this information. The thing is, the other info are manual entries.
Here's an example off the table :
<tbody>
</tbody>
I really don't understand why the sort doesn't take the information to the right of the first column and drag them with the initial info...
Anybody can help me?
Thanks,
I'm using a really simple macro to sort some cata in a table and I'm experiencing some trouble.
The first row of my column is an if formula that reference me a data depending on if the product is required or not. That the main reason why I used a Macro to sort them since everytime the "required" information changes, a new name might appear at the bottom of the list.
Here's the formula : =IFERROR(IF(INGREDIENTS!Q207="P2 - Soft Spec";INGREDIENTS!A207;"");"")
And here's the super basic VBA i'm using :
Sub Sort_P2s()
'
' Sort_P2s Macro
'
ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort.SortFields. _
Add Key:=Range("Tableau3[[#All],[Products]]"), SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("P2s reco").ListObjects("Tableau3").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
This works fine to sort my datas in the first row, but everything else in the table doesn't follow this information. The thing is, the other info are manual entries.
Here's an example off the table :
Products | Submission date | Manuf code | Manuf | Sysco # | Us Foods | Description | Pack size | Delivered Price |
formula | manual entry | manual entry | manual entry | manual entry | manual entry | manual entry | manual entry | manual entry |
Bread | 2014-08-15 | 433872 | Hilltop | 89896 | 634567 | bread, yummy | 8/36 oz | 42,79$ |
<tbody>
</tbody>
I really don't understand why the sort doesn't take the information to the right of the first column and drag them with the initial info...
Anybody can help me?
Thanks,