Excel – 如何select多个列作为范围

我希望和猜测,我们可能有这样的事情:

ws.Range("D").VerticalAlignment 

稍后似乎出错了。

编辑 :以前有问题我提到:

 ws.Range("A:F").VerticalAlignment 

并给出了一个反馈,提到这是正确的。

正如你所看到的,我将要selectA到F的整个列,那么这样做是正确的?

正如你已经做的很好,但你还没有传递VerticalAlignment的参数,假设ws设置正确。

 Range("D:D").VerticalAlignment = xlVAlignCenter Range("A:F").VerticalAlignment = xlVAlignTop 

举几个例子。

嗨,当我需要这样做的时候,这让我感到困惑。 我会尽力解释!

您可以使用select单个单元格(仍然归类为我相信的范围)

 WorkSheet.Cells[row, column] 

要select多个单元格,你可以做这样的事情

 Range startCell = excelSheet.Cells[1,1]; Range endCell = excelSheet.Cells[3,3]; Range myCellCollection = excelSheet.Range[startCell, endCell]; 

希望那有所帮助!

让我知道如果你想要更多的澄清,它可能不是最有效的方式,但它仍然在我的应用程序中运行:)

如何selectA1:F1然后使用

 activecell.EntireColumn.select();