简体   繁体   中英

How to assign Single cell to range?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim TxtRng As Range
    Set TxtRng = ActiveCell

    If Not Intersect(Target, TxtRng) Is Nothing Then

------------Statements           

    End If

End Sub

i am getting an infinite loop. I just want to assign a single cell address to the range (eg. "B6" or "A5", as per selection)

Just set it to the Target:

Set TxtRang = Target

Then you're golden.

Cheers, LC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM