0

是否可以将单元格添加到范围?因为我需要的细胞不是彼此相邻的。

示例:
我需要在一个范围内添加带有 x 的单元格

x 0 xx
x 0 xx
x 0 xx

这可能吗?如果是这样,如何?

谢谢

4

4 回答 4

1

试试这个

VBA:

Range("B26,B19,B13").Select

C#

Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("B26,B19,B13", Type.Missing);
于 2010-06-10T11:00:11.537 回答
1

我找不到解决方法,所以我最终不得不为这些专栏创建新系列。

Excel.SeriesCollection series =  chartPage[1].SeriesCollection();
        Excel.Series TSeries1 = series.NewSeries();
        TSeries1.XValues = xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[chart1.Series[0].Points.Count + 1, 1]];
        TSeries1.Values = xlWorkSheet.Range[xlWorkSheet.Cells[2, 5], xlWorkSheet.Cells[chart1.Series[0].Points.Count + 1, 5]];
        TSeries1.Name = "Setpoint Value";
        Excel.Series TSeries2 = series.NewSeries();
        TSeries2.XValues = xlWorkSheet.Range[xlWorkSheet.Cells[2, 1], xlWorkSheet.Cells[chart1.Series[0].Points.Count + 1, 1]];
        TSeries2.Values = xlWorkSheet.Range[xlWorkSheet.Cells[2, 6], xlWorkSheet.Cells[chart1.Series[0].Points.Count + 1, 6]];
        TSeries2.Name = "Process Value";
于 2021-01-21T20:02:40.637 回答
0

VBA

Option Explicit

Sub ShowAreaUse()

    Dim oRange As Range
    Dim oArea As Range

    'create range with four cells
    Set oRange = Range("C9,E22,F15,I6")

    Debug.Print "Range with four area ranges"
    Debug.Print oRange.Address

    For Each oArea In oRange.Areas
        Debug.Print "    " + oArea.Address
    Next

    'add more cells
    Set oRange = Range(oRange.Address + ",A1:B10")

    Debug.Print "Range with added cells"
    Debug.Print oRange.Address

    For Each oArea In oRange.Areas
        Debug.Print "    " + oArea.Address
    Next

    Debug.Print "Dump Range Cells"

    For Each oArea In oRange
        Debug.Print "    " + oArea.Address
    Next

End Sub
于 2010-06-10T11:13:11.467 回答
0

忽略这个,我的建议没有正常工作

于 2021-01-20T22:44:15.377 回答