1

嗨,我有一个简单的问题,如何在 excel 中选择对角线范围,假设我需要选择(a3 和 b1)或(a3 和 b2)或只是 a1 和 b2 我需要这个范围用于 Sap 仪表板设计(xcelsius)和按住控制键不是一个选项!!

谢谢

4

2 回答 2

1

您不能选择对角线范围。在您的情况下,我认为最好的选择是获取您想要的范围并使用公式复制到列中。

例如,如果要选择 a1、b2 和 c3。在单元格 d1 中输入 =if(a1="";"";a1),在单元格 d2 =if(b2="";"";b2) 和单元格 d3 中 =if(c3="";"";c3 )。然后选择 d1 到 d3。

于 2012-09-18T22:40:01.323 回答
0

我制作了一个用户表单来选择任意方向的任意数量的单元格。我不知道这个有什么用。

Option Explicit
'Run this to open Userform named "Select_Diago"
Sub open_form()
Select_Diago.Show
End Sub

这个东西会弹出来

在此处输入图像描述

输入要选择的单元格数量和需要选择的方向(默认设置为右下)

Private Sub Submit_Click()
Dim Direction As String
Select_Diago.Hide
Direction = "SE"
If NE.Value = True Then Direction = "NE"
If SE.Value = True Then Direction = "SE"
If SW.Value = True Then Direction = "SW"
If NW.Value = True Then Direction = "NW"
Call Select_Diagonal(Direction, TextBox1.Value - 1)
End Sub

Sub Select_Diagonal(Direction As String, Num As Integer)
Dim Diagonal As Range, i As Integer
Dim StrEx As String
'Num = InputBox("How Many cells would you like to select diagonally?")
Select Case Direction
Case "SW"
'For SW
For i = 0 To Num
    On Error Resume Next
    StrEx = StrEx + (Split(Cells(, ActiveCell.Column - i).Address, "$")(1)) + CStr((ActiveCell.Row + i)) + ","
Next i
Case "SE"
'For SE
For i = 0 To Num
    On Error Resume Next
    StrEx = StrEx + (Split(Cells(, ActiveCell.Column + i).Address, "$")(1)) + CStr((ActiveCell.Row + i)) + ","
Next i
Case "NE"
'For NE
For i = 0 To Num
    On Error Resume Next
    StrEx = StrEx + (Split(Cells(, ActiveCell.Column + i).Address, "$")(1)) + CStr((ActiveCell.Row - i)) + ","
Next i
Case "NW"
'For NW
For i = 0 To Num
    On Error Resume Next
    StrEx = StrEx + (Split(Cells(, ActiveCell.Column - i).Address, "$")(1)) + CStr((ActiveCell.Row - i)) + ","
Next i
End Select
StrEx = Left(StrEx, Len(StrEx) - 1)
ActiveSheet.Range(StrEx).Select
End Sub

结果1: 在此处输入图像描述

结果 2: 在此处输入图像描述

于 2016-04-21T10:16:59.930 回答