I was looking for a vba code that could help me match a filename to a pre-specified format. I want it to color a cell red if it doesnt match the format.
For Eg: my format is alrt_OBU_PW_YYYYMMDD_HHMMSS.txt
If the file I browse using application.getopenfilename doesnt match this format, it should give me an error.
Thanks!
Here is what i have done till now-
I have copied the filename into a cell.
FileName = Sheets("Control Sheet").cells(2, "F").Value   
 If FileName = Format("alrt_OBU_PW_" & Format("yyyymmdd") & "_" & Format("hhmmss") & ".txt") Then  
   wqI.range("G21").Interior.ColorIndex = 43  
   Else: wqI.range("G21").Interior.ColorIndex = 3  
End If
 
     
    