-2

如何将 B2 列添加到 E2 并将其放入 F2 列。在这种情况下,这会动态地继续下去,直到 B12 + E12 = F12?

子计算比率()

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(0, 1).FormulaR1C1 = "Others #Dev/#Deals"

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).FormulaR1C1 = "=Iferror(RC[-8]/RC[-7],0)"

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight).Offset(0, 1))
    oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight)).Copy
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(0, 1).FormulaR1C1 = "Country/Area #Dev/#Deals"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).FormulaR1C1 = "=Iferror(RC[-7]/RC[-6],0)"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight).Offset(0, 1))
    oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight)).Copy
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(0, 1).FormulaR1C1 = "Geo #Dev/#Deals"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).FormulaR1C1 = "=Iferror(RC[-6]/RC[-5],0)"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight).Offset(0, 1))
    oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight)).Copy
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(0, 1).FormulaR1C1 = "Corporate #Dev/#Deals"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).FormulaR1C1 = "=Iferror(RC[-5]/RC[-4],0)"
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight).Offset(0, 1))
    oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight)).Copy
    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False

    oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(0, 1).FormulaR1C1 = "Total # Of Deals Per Level"
    'oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).FormulaR1C1 = "=SUM(B2:E2)"
   ' oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0).AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Offset(1, 0), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight).Offset(0, 1))
   ' oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("A1").End(xlToRight), oEXLWB.Sheets("Country").Range("A1").End(xlDown).End(xlToRight)).Copy
   ' oEXLWB.Sheets("Country").Range("A1").End(xlToRight).PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False

    oEXLWB.Sheets("Country").Range("B:I").Delete
    oEXLWB.Sheets("ExportDeviations").Columns(oEXLWB.Sheets("ExportDeviations").Range("A4").End(xlToRight).Column).Delete
End Sub

在此处输入图像描述

4

1 回答 1

0
Sub hideunwantedcolumns()
    pvtRowCount = pvtTable.TableRange1.Rows.count
    pvtColumnCount = pvtTable.TableRange1.Columns.count
'    Set pvtTotRange = pvtTable.DataBodyRange.Range()
    Set All = oEXLWB.Sheets("PVT_country").Range("A1:R10000")
'    pvtTable.TableRange1.Columns(pvtTable.TableRange1.Columns.Count).Copy Destination:=oEXLWB.Sheets("PVT_Deal_Value").Range("R1")

    pvtTable.PivotFields("Approval Level").PivotItems("Country/Area").datarange.Copy Destination:=oEXLWB.Sheets("Country").Range("B2")
    pvtTable.PivotFields("Approval Level").PivotItems("Geo").datarange.Copy Destination:=oEXLWB.Sheets("Country").Range("D2")
    pvtTable.PivotFields("Approval Level").PivotItems("Corporate").datarange.Copy Destination:=oEXLWB.Sheets("Country").Range("F2")

    pvtTable.PivotFields("Approval Level").PivotItems("Country/Area").LabelRange.Copy Destination:=oEXLWB.Sheets("Country").Range("B1")
    pvtTable.PivotFields("Approval Level").PivotItems("Geo").LabelRange.Copy Destination:=oEXLWB.Sheets("Country").Range("D1")
    pvtTable.PivotFields("Approval Level").PivotItems("Corporate").LabelRange.Copy Destination:=oEXLWB.Sheets("Country").Range("F1")
        pvtTable.TableRange1.Columns(pvtTable.TableRange1.Columns.count).SpecialCells(xlCellTypeConstants).Copy Destination:=oEXLWB.Sheets("Country").Range("H1")
    pvtTable.TableRange1.Columns(pvtTable.TableRange1.Columns.count - 1).SpecialCells(xlCellTypeConstants).Copy Destination:=oEXLWB.Sheets("Country").Range("I1")
    pvtTable.TableRange1.Columns(1).SpecialCells(xlCellTypeConstants).Copy Destination:=oEXLWB.Sheets("Country").Range("A1")

    oEXLWB.Sheets("Country").Columns(2).Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    oEXLWB.Sheets("Country").Columns(2).Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
     oEXLWB.Sheets("Country").Range("B1") = "Others(Count)"
    oEXLWB.Sheets("Country").Range("C1") = "Others(Sum)"
'    oEXLWB.Sheets("Deal_Value").Range("C2").AutoFill Destination:=oEXLWB.Sheets("Deal_Value").Range(oEXLWB.Sheets("Deal_Value").Range("C2"), oEXLWB.Sheets("Deal_Value").Range("C2").End(xlDown))
    oEXLWB.Sheets("Country").Range("B2").FormulaR1C1 = "=RC[9]- (RC[2] + RC[4] + RC[6])"
    oEXLWB.Sheets("Country").Range("B2").AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("B2"), oEXLWB.Sheets("Country").Range("A1").End(xlDown).Offset(0, 1))

    oEXLWB.Sheets("Country").Range("C2").FormulaR1C1 = "=RC[7]- (RC[2] + RC[4] + RC[6])"
    oEXLWB.Sheets("Country").Range("C2").AutoFill Destination:=oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("C2"), oEXLWB.Sheets("Country").Range("A1").End(xlDown).Offset(0, 2))

    oEXLWB.Sheets("Country").Range(oEXLWB.Sheets("Country").Range("B2"), oEXLWB.Sheets("Country").Range("A1").End(xlDown).Offset(0, 2)).Copy
    oEXLWB.Sheets("Country").Range("B2").PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks:=False, Transpose:=False oEXLWB.Sheets("Country").Columns(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Column).Delete    oEXLWB.Sheets("Country").Columns(oEXLWB.Sheets("Country").Range("A1").End(xlToRight).Column).Delete
于 2014-02-25T16:20:49.707 回答