【问题标题】:how to select a range diagonally in excel?如何在excel中对角选择一个范围?
【发布时间】:2012-06-24 03:42:30
【问题描述】:

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

谢谢

【问题讨论】:

  • 为什么 Ctrl 键不是一个选项?这就是它的工作原理。

标签: excel sap dashboard xcelsius


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    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:

    【讨论】:

    • 很好地使用单选按钮使其直观。
    猜你喜欢
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    相关资源
    最近更新 更多