I'm running a basic code that will detect when certain columns stop having any data in their cells. I'm looking at the cells inside the area between K2 and W31.
It seems to work when I focus in on one worksheet, but when I run the entire code, it returns a value of 5 for x ( which is not correct).
I am wondering if someone might have an idea of what I was doing wrong, or what I should check.
Thank you
Code below:
Sub Macro()
Dim x, y, z, count As Integer
count = 2
x = 0
y = 2
z = 11
Dim sheet As Worksheet
For Each sheet In ThisWorkbook.Worksheets
If sheet.Name <> "Main Analysis" Then
count = count + 1
For z = 11 To 23
For y = 2 To 31
If Cells(y, z) = "" Then x = x + 1 Else x = 0
Next y
Worksheets("Main Analysis").Cells(count, z) = x
x = 0
y = 2
Next z
z = 11
MsgBox sheet.Name
MsgBox count
End If
Next sheet
End Sub
Bookmarks