Enter Text/Characters with a Double-Click of the Mouse

0

I found the following code on this website but i want to change the "x" to be whatever tect is in cell F5. can anyone help?

Private Sub Worksheet_BeforeDoubleClick( _
            ByVal Target As Range, Cancel As Boolean)
    Dim rInt As Range
    Dim rCell As Range

    Set rInt = Intersect(Target, Range("E5:EH103"))
    If Not rInt Is Nothing Then
        For Each rCell In rInt
            rCell.Value = "x"
        Next
    End If

    Set rInt = Nothing
    Set rCell = Nothing
    Cancel = True

End Sub
Answer
Discuss

Answers

0
Selected Answer
Private Sub Worksheet_BeforeDoubleClick( _
            ByVal Target As Range, Cancel As Boolean)
    Dim rInt As Range
    Dim rCell As Range

    Set rInt = Intersect(Target, Range("E5:EH103"))
    If Not rInt Is Nothing Then
        For Each rCell In rInt
            rCell.Value = Range("F5").Value
        Next
    End If

    Set rInt = Nothing
    Set rCell = Nothing
    Cancel = True

End Sub

That should do it.

Discuss

Discussion

This is amazing, thank you! quick question, if "F5" is a merged cell (could be different sizes) could this code bring through the whole thing? for example it could be 3 columns long or 9 columnsw long etc
PrincessD1 (rep: 2) Mar 23, '17 at 5:48 am
It shouldn't matter.
don (rep: 1412) Mar 23, '17 at 12:32 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login