I have code that works in some situations but not in others.
I have this code:
Public Sub ListBox2_LostFocus()
ListBox2.Height = 15
With ListBox2
ThisIs_Sheet1_Test = "'"
For i = 0 To .ListCount - 1
If .Selected(i) Then
ThisIS_Sheet1_Test = ThisIs_Sheet1_Test & .List(i) & "','"
End If
Next i
End With
ThisIs_Sheet1_Test = Left(ThisIs_Sheet1_Test, Len(ThisIs_Sheet1_Test) - 2)
End Sub
that produces "ThisIs_Sheet1_Test". So when I run the code below, it gives me the selected values in the listbox.
Public Sub dummy()
Dim SheetName As String
SheetName = ActiveSheet.Name
Sheets("Sheet1").Range("I5", "I5") = ThisIs_Sheet1_Test
End Sub
However, when I use
Sheets("Sheet1").Range("I5", "I5") = "ThisIs_" & SheetName & "_Test"
I get the value of "ThisIs_SheetName_Test" which is obviously not what I'm looking for.
How to I bring in the value and then have the VBA recognize that it should be pulling in the earlier value?