View Full Version : [SOLVED:] Select working(Active) range with mouse
idnoidno
08-14-2017, 02:43 AM
I use a mouse to select a range,for example Q6:Q10.
I want to use like ActiveCell expression,how can I do in my vba code?
idnoidno
08-14-2017, 03:08 AM
Mr. mana
I don't have any idea about your answer.Could you explain it further?
If TypeName(Selection) = "Range" Then MsgBox Selection.Address(0, 0)
idnoidno
08-14-2017, 07:19 AM
I got it,and one more question.
For example,Q6:Q10
Selection.column=17,right?
How could I get the row numbers of 6 and 10?
With Selection
MsgBox .Row & vbLf & .Row + .Rows.Count - 1
End With
mdmackillop
08-14-2017, 07:36 AM
If TypeName(Selection) = "Range" Then
MsgBox Selection(1).Row
MsgBox Selection(Selection.Rows.Count).Row
x = Selection.Address(1, 1)
MsgBox Replace(Split(x, "$")(2), ":", "")
MsgBox Split(x, "$")(4)
End If
idnoidno
08-14-2017, 06:05 PM
If the range is Q1: Q10, the mouse click is Q2: Q8, how to deal with Q2: Q8?
you can use "resize & offset"
idnoidno
08-14-2017, 06:26 PM
Mr.mana
Could you give me a example?
It will be appreciated.
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-resize-property-excel?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/VBA/Excel-VBA/articles/range-offset-property-excel (http://https://msdn.microsoft.com/VBA/Excel-VBA/articles/range-offset-property-excel)
idnoidno
08-14-2017, 07:32 PM
氏マナは、ご指導ありがとうございました
mdmackillop
08-15-2017, 04:48 AM
If the range is Q1: Q10, the mouse click is Q2: Q8, how to deal with Q2: Q8?
If the mouse click is Q2: Q8 then the Selection is Q2: Q8
Dim X as Range
With Selection
Set X = Range(.Cells(2), .Cells(8))
End With
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.