我有一张非常大的表格,大约 150 列,其中大部分包含公式。当我想对输入到不使用公式的单元格的数据进行排序时,它会弄乱整个工作表。- 输入单元格不在一起
目前我在 VBA 中的解决方案是将单元格复制到另一个(隐藏的)工作表,排序并将其全部放回。我只是觉得这对于一个看似简单的任务来说工作量太大了。有没有更聪明的方法来解决这个问题?
编辑
qua @varocarbas 我尝试了以下代码:
Private Sub sortInputButton_Click()
' This sub sorts the inpur, without messing up the references [hopefully]
Dim rowCount As Integer
Dim colCount As Integer
rowCount = countItems
colCount = 180
Dim inputRange As Range
Set inputRange = Sheets("Input").Range("A3")
Set inputRange = inputRange.Resize(rowCount, colCount)
Dim targetRange As Range
On Error Resume Next ' If range is nothing, throws an error - we don't want that
Set targetRange = inputRange.SpecialCells(xlCellTypeConstants)
On Error GoTo 0
If targetRange.Cells.count > 0 Then
Sheets("Input").Select
targetRange.Select
Call targetRange.Sort(Sheets("Input").Range("A3"), xlAscending)
End If
End Sub
但这给了我错误the command you chose cannot be performed with multiple selections. Select a single range and click the command again.