Look for blank cells on a non active sheet?

danbates

Active Member
Joined
Oct 8, 2017
Messages
277
Office Version
2016
Platform
Windows
Hi,

Please can someone help me?

I have this code that works fine for me when the Daily Check Sheet is active.
I now need it altering so the code still looks for the same blanks cells on the Daily Check Sheet but when the sheet isn't active.

Here is my code:

Code:
Sub DaysandMonthsandInitials()

ThisWorkbook.Sheets("Daily Check Sheet").Activate


ActiveCell.Offset(0, 1).Select


D = WorksheetFunction.CountBlank(ActiveCell.Resize(14))
M = WorksheetFunction.CountBlank(ActiveCell.Offset(16))


'MsgBox D & ", " & M


If D > 0 And M > 0 Then


DaysandMonths


ElseIf D = 0 And M > 0 Then


Months


ElseIf D > 0 And M = 0 Then


Days


End If
End Sub
Any help would be appreciated.

Thanks

Dan
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
8,896
You cannot select a cell on a sheet unless it is the active sheet. Is the active cell on "Daily Check Sheet" always the same and if so, what is it?
 

Watch MrExcel Video

Forum statistics

Threads
1,095,168
Messages
5,442,792
Members
405,196
Latest member
rmuir12

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top