I have a vba code in access that gets data from an excel page and transfers it in excel through variables using a button in an access form. If some data requested aren't in the excel file, I want it to show a msgbox showing me which data weren't transfered. To do that I'm using boolean variables and with "IF" I check if the variable with the stored data from excel is empty.
Var1IF = True
Var1 = Sheet1.Cells(95, 80).Value
If Var1 = "" Then
Var1IF = False
End If
No matter what I do Var1IF always returns as False. Even if Var1 has data in it or not (Since the cells from excel might have both numbers and letters, Var1 is a String).
I even did the opposite and it returned False again:
Var1IF = True
Var1 = Sheet1.Cells(95, 80).Value
If Var1 <> "" Then
Var1IF = False
End If
Edit: Declarations:
Dim oXLApp As Object, wb As Object
Dim Sheet1 As Object
Dim Var1 as String
Dim Var1IF as Boolean
Set oXLApp = GetObject(, "Excel.Application")
Set Sheet1 = oXLApp.Sheets("Sheet1")