Forum Discussion

TheTallman's avatar
TheTallman
Copper Contributor
Jul 05, 2021
Solved

Excel - Enhance excel workbook

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 proj...
  • HansVogelaar's avatar
    Jul 05, 2021

    TheTallman 

     

    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.

Resources