UnsolvedCoding
Technical User
Here's a brand new one for me.
The code is checking to see if the cells used to verify information and hold information are blank and if they are its to turn an indicator called Flag to 1. Problem is, the worksheet is blank, the cells are all empty and the if statment isn't turning Flag to 1.
If I highlight the section of code that shows the value of the cell it says the cell is empty but for some reason the if statment simply skips turning the flag indicator to 1.
Neither I nor my co-workers can figure out why. We have deleted all the cells, replaced all the cells and even populated a few of the cells to check if the values were pulling through (they are) but we simply can't get Flag = 1.
We have tried = Empty and = "" but neither works.
Ideas?
Here is some preceding code and the entire sub that checks the cell data, J is the counter used in the next loop that calls this sub and it indicates which worksheet in the workbook to look at.
Public J as long
Public Flag As Byte
Public WS_Count As Integer
WS_Count = Application.Sheets.Count
for J = 1 to WS_Count
' Do stuff like open workbook, get workbook name and path
Check_For_Data
' Do more stuff or go to the next worksheet
Next J
Private Sub Check_For_Data()
If Trim(Worksheets(J).Range("AD25").Value) = Empty And _
Trim(Worksheets(J).Range("AF35").Value) = Empty And _
Trim(Worksheets(J).Range("AJ35").Value) = Empty And _
Trim(Worksheets(J).Range("AK35").Value) = Empty And _
Trim(Worksheets(J).Range("AL35").Value) = Empty And _
Trim(Worksheets(J).Range("ar35").Value) = Empty And _
Trim(Worksheets(J).Range("D1").Value) = Empty And _
Trim(Worksheets(J).Range("E25").Value) = Empty And _
Trim(Worksheets(J).Range("E3").Value) = Empty And _
Trim(Worksheets(J).Range("H26").Value) = Empty And _
Trim(Worksheets(J).Range("H28").Value) = Empty And _
Trim(Worksheets(J).Range("h3").Value) = Empty And _
Trim(Worksheets(J).Range("H9").Value) = Empty And _
Trim(Worksheets(J).Range("i3").Value) = Empty And _
Trim(Worksheets(J).Range("J3").Value) = Empty And _
Trim(Worksheets(J).Range("J5").Value) = Empty And _
Trim(Worksheets(J).Range("k10").Value) = Empty Then
Flag = 1
End If
If Trim(Worksheets(J).Range("K32").Value) = Empty And _
Trim(Worksheets(J).Range("K33").Value) = Empty And _
Trim(Worksheets(J).Range("K5").Value) = Empty And _
Trim(Worksheets(J).Range("R5").Value) = Empty And _
Trim(Worksheets(J).Range("R7").Value) = Empty And _
Trim(Worksheets(J).Range("S25").Value) = Empty And _
Trim(Worksheets(J).Range("S26").Value) = Empty And _
Trim(Worksheets(J).Range("U3").Value) = Empty And _
Trim(Worksheets(J).Range("U35").Value) = Empty And _
Trim(Worksheets(J).Range("u5").Value) = Empty And _
Trim(Worksheets(J).Range("V35").Value) = Empty Then
Flag = 1
End If
End Sub
The code is checking to see if the cells used to verify information and hold information are blank and if they are its to turn an indicator called Flag to 1. Problem is, the worksheet is blank, the cells are all empty and the if statment isn't turning Flag to 1.
If I highlight the section of code that shows the value of the cell it says the cell is empty but for some reason the if statment simply skips turning the flag indicator to 1.
Neither I nor my co-workers can figure out why. We have deleted all the cells, replaced all the cells and even populated a few of the cells to check if the values were pulling through (they are) but we simply can't get Flag = 1.
We have tried = Empty and = "" but neither works.
Ideas?
Here is some preceding code and the entire sub that checks the cell data, J is the counter used in the next loop that calls this sub and it indicates which worksheet in the workbook to look at.
Public J as long
Public Flag As Byte
Public WS_Count As Integer
WS_Count = Application.Sheets.Count
for J = 1 to WS_Count
' Do stuff like open workbook, get workbook name and path
Check_For_Data
' Do more stuff or go to the next worksheet
Next J
Private Sub Check_For_Data()
If Trim(Worksheets(J).Range("AD25").Value) = Empty And _
Trim(Worksheets(J).Range("AF35").Value) = Empty And _
Trim(Worksheets(J).Range("AJ35").Value) = Empty And _
Trim(Worksheets(J).Range("AK35").Value) = Empty And _
Trim(Worksheets(J).Range("AL35").Value) = Empty And _
Trim(Worksheets(J).Range("ar35").Value) = Empty And _
Trim(Worksheets(J).Range("D1").Value) = Empty And _
Trim(Worksheets(J).Range("E25").Value) = Empty And _
Trim(Worksheets(J).Range("E3").Value) = Empty And _
Trim(Worksheets(J).Range("H26").Value) = Empty And _
Trim(Worksheets(J).Range("H28").Value) = Empty And _
Trim(Worksheets(J).Range("h3").Value) = Empty And _
Trim(Worksheets(J).Range("H9").Value) = Empty And _
Trim(Worksheets(J).Range("i3").Value) = Empty And _
Trim(Worksheets(J).Range("J3").Value) = Empty And _
Trim(Worksheets(J).Range("J5").Value) = Empty And _
Trim(Worksheets(J).Range("k10").Value) = Empty Then
Flag = 1
End If
If Trim(Worksheets(J).Range("K32").Value) = Empty And _
Trim(Worksheets(J).Range("K33").Value) = Empty And _
Trim(Worksheets(J).Range("K5").Value) = Empty And _
Trim(Worksheets(J).Range("R5").Value) = Empty And _
Trim(Worksheets(J).Range("R7").Value) = Empty And _
Trim(Worksheets(J).Range("S25").Value) = Empty And _
Trim(Worksheets(J).Range("S26").Value) = Empty And _
Trim(Worksheets(J).Range("U3").Value) = Empty And _
Trim(Worksheets(J).Range("U35").Value) = Empty And _
Trim(Worksheets(J).Range("u5").Value) = Empty And _
Trim(Worksheets(J).Range("V35").Value) = Empty Then
Flag = 1
End If
End Sub