对行总计进行排序

时间:2016-09-04 10:04:58

标签: excel vba excel-vba sorting

我使用Excel VBA来转移某些数据并将2个项目用作行。我能够排序 B列(带有数据的列 - 总和/计数)。但是,我还想在行总数的基础上按降序对其进行排序。我到目前为止的代码是:

app.post('/webhook/', function (req, res) {
    // addPersistentMenu();
    let messaging_events = req.body.entry[0].messaging;
    for (let i = 0; i < messaging_events.length; i++) {
        let event = req.body.entry[0].messaging[i];
        let sender = event.sender.id;
        if (event.message && event.message.text) {
            let text = event.message.text;
            console.log(text);
            A.prepare(function (text) {
                B.write(text, function (response) {
                    sendTextMessage(sender,response.message)
                    return response.message;
                });
            });   
        }
        if (event.postback) {
            let text = JSON.stringify(event.postback);
            sendTextMessage(sender, "Postback received: "+text.substring(0, 200));
            continue;
        }
    }
    res.sendStatus(200)
});

有什么想法吗?image showing the pivot table I got so far

2 个答案:

答案 0 :(得分:0)

如果CurrentSection是您要进行第二次排序的字段,那么这可能就是您要找的内容,

pt.PivotFields("CurrentSection").AutoSort Order:=xlDescending, Field:="Count of LeadStatus"

答案 1 :(得分:0)

For Each pf In pt.RowFields
                  pf.AutoSort xlDescending, pf.SourceName
                Next pf
                For Each pf In pt.ColumnFields
                    pf.AutoSort xlDescending, pf.SourceName
                Next pf
                pt.PivotFields("LeadStatus").AutoSort Order:=xlDescending, Field:="Count of LeadStatus"