I have a VBA code that opens explorers File Dialog Folder Picker. Is it possible to…
- User
I have a VBA code that opens explorers File Dialog Folder Picker. Is it possible to force the File Dialog Folder Picker to open dirctly into this folder G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS .
Sub FileList()
'USED BY ALL CONTRACTOR FILES - DO NOT DELETE
Application.EnableEvents = False Range("A5:A100").ClearContents Application.EnableEvents = True 'Open folder to copy files Dim xFSO As Object Dim xFolder As Object Dim xFile As Object Dim xFiDialog As FileDialog Dim xPath As String Dim i As Integer Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker) If xFiDialog.Show = -1 Then xPath = xFiDialog.SelectedItems(1) End If Set xFiDialog = Nothing If xPath = "" Then Exit Sub Set xFSO = CreateObject("Scripting.FileSystemObject") Set xFolder = xFSO.GetFolder(xPath) i = 5 ' Modified line to start the list from A4 without row spaces between the links. For Each xFile In xFolder.files ActiveSheet.Hyperlinks.Add Cells(i, 1), xFile.path, , , xFile.Name i = i + 1 ' Increment I by 1 for each file. Next End Sub
- Assistant
Yes, it is possible to force the File Dialog Folder Picker to open directly into a specific folder. Just add the following line of code before the If statement:
xFiDialog.InitialFileName = "G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS"
The updated code should look like this:
Sub FileList()
'USED BY ALL CONTRACTOR FILES - DO NOT DELETE
Application.EnableEvents = False Range("A5:A100").ClearContents Application.EnableEvents = True 'Open folder to copy files Dim xFSO As Object Dim xFolder As Object Dim xFile As Object Dim xFiDialog As FileDialog Dim xPath As String Dim i As Integer Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker) xFiDialog.InitialFileName = "G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS" If xFiDialog.Show = -1 Then xPath = xFiDialog.SelectedItems(1) End If Set xFiDialog = Nothing If xPath = "" Then Exit Sub Set xFSO = CreateObject("Scripting.FileSystemObject") Set xFolder = xFSO.GetFolder(xPath) i = 5 ' Modified line to start the list from A4 without row spaces between the links. For Each xFile In xFolder.files ActiveSheet.Hyperlinks.Add Cells(i, 1), xFile.path, , , xFile.Name i = i + 1 ' Increment I by 1 for each file. Next End Sub
- User
I have text generated by a formula in a cell. the text is presented as follows; '15-06-2023 Hot & Cold Water Temperature Checks Total Water Compliance'. If conditional formatting can detect the date in the text, which will always be at the beginning of the string. I need a formula to use in conditional formatting to identify dates that are within 30 days of Today.
- Assistant
Yes, you can use a formula in conditional formatting to identify dates that are within 30 days of today. Here is the formula you can use:
=SEARCH(TEXT(TODAY()+30,"dd-mm-yyyy"),A1)=1
Assuming the text generated by the formula is in cell A1, the above formula will check if the date in the text is within 30 days of today. If it is, it will return TRUE, and the conditional formatting will be applied. Here's how to set up the conditional formatting:
- Select the cell(s) containing the text generated by the formula.
- Go to the Home tab, click on Conditional Formatting, and select New Rule.
- In the New Formatting Rule dialog box, select "Use a formula to determine which cells to format."
- In the "Format values where this formula is true" field, enter the formula: =SEARCH(TEXT(TODAY()+30,"dd-mm-yyyy"),A1)=1
- Click on the Format button to choose the formatting you want to apply to the cells that meet the condition.
- Click OK to close the New Formatting Rule dialog box.
This should apply the conditional formatting to the cells that contain a date that is within 30 days of today.