Setting selection to Nothing when programming Excel

后端 未结 17 1765
误落风尘
误落风尘 2021-02-02 09:35

When I create a graph after using range.copy and range.paste it leaves the paste range selected, and then when I create a graph a few lines later, it uses the selection as the f

相关标签:
17条回答
  • 2021-02-02 09:50

    If you select a cell in an already selected range, it will not work. But, Selecting a range outside the original selection will clear the original selection.

    '* The original selection *' ActiveSheet.range("A1:K10").Select

    '* New Selections *' Activesheet.Range("L1").Select

    '* Then *' Activesheet.Range("A1").Select

    0 讨论(0)
  • 2021-02-02 09:53

    Do statement as below:

    ActiveSheet.Cells(ActiveWindow.SplitRow+1,ActiveWindow.SplitColumn+1).Select
    
    0 讨论(0)
  • 2021-02-02 09:55

    There is a way to SELECT NOTHING that solve your problem.

    1. Create a shape (one rectangle)
    2. Name it in Shapes Database >>> for example: "Ready"
    3. Refer to it MYDOC.Shapes("Ready") and change the visibility to False

    When you want that Excel SELECT NOTHING do it:

    MYDOC.Shapes("Ready").visible=True
    MYDOC.Shapes("Ready").Select
    MYDOC.Shapes("Ready").visible=False
    

    This HIDE the selection and nothing still selected in your window PLUS: The word "Ready" is shown at the Left Top in your Sheet.

    0 讨论(0)
  • 2021-02-02 09:55

    Selection(1, 1).Select will select only the top left cell of your current selection.

    0 讨论(0)
  • 2021-02-02 09:57

    I do not think that this can be done. Here is some code copied with no modifications from Chip Pearson's site: http://www.cpearson.com/excel/UnSelect.aspx.

    UnSelectActiveCell

    This procedure will remove the Active Cell from the Selection.

    Sub UnSelectActiveCell()
        Dim R As Range
        Dim RR As Range
        For Each R In Selection.Cells
            If StrComp(R.Address, ActiveCell.Address, vbBinaryCompare) <> 0 Then
                If RR Is Nothing Then
                    Set RR = R
                Else
                    Set RR = Application.Union(RR, R)
                End If
            End If
        Next R
        If Not RR Is Nothing Then
            RR.Select
        End If
    End Sub
    

    UnSelectCurrentArea

    This procedure will remove the Area containing the Active Cell from the Selection.

    Sub UnSelectCurrentArea()
        Dim Area As Range
        Dim RR As Range
    
        For Each Area In Selection.Areas
            If Application.Intersect(Area, ActiveCell) Is Nothing Then
                If RR Is Nothing Then
                    Set RR = Area
                Else
                    Set RR = Application.Union(RR, Area)
                End If
            End If
        Next Area
        If Not RR Is Nothing Then
            RR.Select
        End If
    End Sub
    
    0 讨论(0)
  • 2021-02-02 10:00

    Tried all your suggestions, no luck , but here's an idea that worked for me select a cell out of your selection range (say AAA1000000) and then select the A1 again

    Range("AAA1000000").Activate

    Range("A1").Activate

    Guy

    0 讨论(0)
提交回复
热议问题