Jul 05 2021 10:33 AM
Hi All, I created a workbook with one command button that give a functionality to end user to browse a file and once file chosen its name get highlighted in workbook(yellow color). In my ongoing project I want to enhance it in following manner ..
3. Also, if user attempted to pick a same file that was already in log with green color then warning should pop up “File was picked on date ??/??/????.
I attached a sample file so please help how I can add these functionality to it.
Jul 05 2021 12:21 PM
Solution
1) Change the line
UserSelectedFile = Application.GetOpenFilename
to
UserSelectedFile = Application.GetOpenFilename(FileFilter:="Text Files (*.txt),*.txt")
2) Use
Range("B8:C8").Insert Shift:=xlShiftDown
Range("B8:C8").Interior.Color = vbYellow
Range("B8").Value = Mid(UserSelectedFile, InStrRev(UserSelectedFile, Application.PathSeparator) + 1)
Range("C8").Value = Date ' or Now
Range("B9:C9").Interior.Color = vbGreen
See the attached version.
Jul 05 2021 07:57 PM
Jul 05 2021 12:21 PM
Solution
1) Change the line
UserSelectedFile = Application.GetOpenFilename
to
UserSelectedFile = Application.GetOpenFilename(FileFilter:="Text Files (*.txt),*.txt")
2) Use
Range("B8:C8").Insert Shift:=xlShiftDown
Range("B8:C8").Interior.Color = vbYellow
Range("B8").Value = Mid(UserSelectedFile, InStrRev(UserSelectedFile, Application.PathSeparator) + 1)
Range("C8").Value = Date ' or Now
Range("B9:C9").Interior.Color = vbGreen
See the attached version.