Reviewing All Cells

raccoon588

Board Regular
Joined
Aug 5, 2016
Messages
118
I have a calendar in excel populated with a years worth of dates. I would like to be able to check for a file based off of the date in the cell and then change the color of the cell based on if that file exists or not. I was able to create the following code but i am not sure how to get it to review ALL cells in one go. Right now i manually change the range. I'm stuck on have it automatically look at each cell and then change that cell based on finding the file. The bellow code works except it is going to be very cumbersome to write this line of code for every day in the calendar year. (the file location is just some sample files once i have it up and running all files will be saved in one location for an entire year)

Code:
Sub Find_File()Dim MyFile As String
MyFile = "\\hinas1\mfg\led\ssl paperwork\p552p558\july2017\p55xfirstarticle" & " " & Range("A12").Text & " " & "*.xlsm"
If Dir(MyFile) <> "" Then
Range("A12").Interior.ColorIndex = 10
Else
Range("A12").Interior.ColorIndex = 3
End If
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Here i san example of how you can loop:

Code:
For i = 1 To 5
    MsgBox Range("A" & i).Address(0, 0)
Next

so instead of using 12 use a variable. In this case the variable is i.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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