Looping Through Sheets in a Workbook for a Specific Cell to be Blank

bill1967

New Member
Joined
Mar 24, 2015
Messages
13
I have looked on this site and many others but not finding the exact piece of code I am looking for. Probably not asking correctly. I have a workbook that has a worksheet for each day of the year, each formatted exactly the same an labelled like this "mmddyy". What I am attempting to find is a piece of code that will loop through each sheet looking at a specific cell location in each sheet D1, looking for the first sheet where the cell is blank. Then the remainder of the macro doing several copy/paste commands then finishing by pasting a date in the cell D1. That way when the script runs the next day it will pass over the one that was just pasted to. I had a script that did this at my last job but did not think to save the code because I might need it again in the future. Any help would be appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try:
Code:
Sub FindBlankCell()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    For Each ws In Sheets
        If ws.Range("D1") = "" Then
            'your code here to do the copy/pasting
            Exit For
        End If
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top