| |

VerySource

 Forgot password?
 Register
Search
View: 2368|Reply: 4

How to get the position (row number and column number) of all cells selected by mouse in Excel

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-7 18:00:01
| Show all posts |Read mode
How to get the position (row number and column number) of all cells selected by mouse in Excel
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 United States

Post time: 2020-7-30 20:30:01
| Show all posts
Add the following code to the required sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Target.Offset(0, 0) = Target.Row&","&Target.Column
   
End Sub

The result is that the row number, column number are automatically entered in the corresponding cell
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-30 21:00:02
| Show all posts
As long as the mouse clicks on a cell, the row number and column number can be automatically obtained. Is such a result needed?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Japan

Post time: 2020-7-31 12:45:01
| Show all posts
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim Rng As Range
    For Each Rng In Target
        MsgBox "Row:"&Rng.Row&";Col:"&Rng.Column
    Next
End Sub
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-31 14:30:01
| Show all posts
Master, mine is only suitable for single selection of a certain cell, yours can be selected in pieces, great. . .
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list