I have a vba macro open a workbook and pull some data to display in a user form and it works fine.
Now I want to close the workbook it opens before it displays the data but when I close the workbook after getting the values but before displaying it they don't display. I don't know if I need to dim as variant and set the values but when I try that I get an object error. so im now out of my depth.
ie. my vba contains a heap of these from textbox 1 to 10, but when I close the workbook the user form just has blank values. (note bImported is just stolen from another piece of code I had that works how I want and just haven't renamed it to suit...)
Now I want to close the workbook it opens before it displays the data but when I close the workbook after getting the values but before displaying it they don't display. I don't know if I need to dim as variant and set the values but when I try that I get an object error. so im now out of my depth.
ie. my vba contains a heap of these from textbox 1 to 10, but when I close the workbook the user form just has blank values. (note bImported is just stolen from another piece of code I had that works how I want and just haven't renamed it to suit...)
VBA Code:
Giftcards.TextBox1 = Format(wb.Sheets("Giftcards").Range("T2").Value, "$ #,###")
' Close the workbook if it was opened by the code
If bImported Then
wb.Close SaveChanges:=False
End If
Application.ScreenUpdating = True
Giftcards.Show