FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,364
- Office Version
- 365
- 2016
- Platform
- Windows
I initially built a Index/Match function in VBA that looped thru the rows, but would like to speed up the process with the Evaluate function. This is where I've gotten to, but it simply repeats the first value from Sheet2.
I must be missing something simple, but can't figure it out. Also, instead of using the sheet name, is it possible to use the sheet codename?
I must be missing something simple, but can't figure it out. Also, instead of using the sheet name, is it possible to use the sheet codename?
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim LastRow As Long
Dim myRow As Long
If Target.CountLarge > 1 Then Exit Sub
Cancel = True
LastRow = Me.Range("B" & Rows.Count).End(xlUp).Row
If Not Intersect(Target, Sheet1.Range("E1")) Is Nothing Then
If Target.Value = "Yes" Then: Target.Value = "No": Else: Target.Value = "Yes"
If Me.Range("ShortName").Value2 = "No" Then
Me.Range("A4:A" & LastRow).Value = Evaluate("INDEX('Sheet2'!C:C,MATCH(B4:B" & LastRow & ",'Sheet2'!B:B,0))")
Else
Me.Range("A4:A" & LastRow).Value = Evaluate("INDEX('Sheet2'!A:A,MATCH(B4:B" & LastRow & ",'Sheet2'!B:B,0))")
End If
Me.Columns(1).AutoFit
End If
End Sub