how to put dialog box to open a file ?

fluffyvampirekitten

Board Regular
Joined
Jul 1, 2015
Messages
72
I want a dialog box to prompt user to open MISSINGUSERNAMEDEPT file .

any ideas?
Thanks in advance



Here are my codes below:

Code:
Private Sub Simpat4_Missing_UserName_Dept()
'
' Update User Name and Dept from Missing User name & dept xlsx file
' Step 29
'
Dim MaxRowNum, RowNum As Long
    With Application
        .ScreenUpdating = False
        .Calculation = xlManual
    End With
        
    'Activate the SimPat ws
    Sheets("SimPat").Select
    'Find the max number of row - Column M - Creation ID
    MaxRowNum = Range("M" & Rows.Count).End(xlUp).Row
    
    'Find the row with the USERNAME & DEPT - "NOT INDICATED" and use a vlookup Function
    RowNum = 1
    
    For RowNum = 1 To MaxRowNum
        If UCase(Cells(RowNum, 16)) Like "*NOT INDICATED*" Then
                                  
            'Vlookup User Name from the file MISSINGUSERNAMEDEPT.xlsx
            Range("P" & RowNum).FormulaR1C1 = "= IF(ISNA(VLOOKUP(RC[-3],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!R1:R1048576,2,0)), ""NOT INDICATED"",(VLOOKUP(RC[-3],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!R1:R1048576,2,0)))"
                                        
        End If
        
        If UCase(Cells(RowNum, 17)) Like "*NOT INDICATED*" Then
        
            'Vlookup Dept from the file MISSINGUSERNAMEDEPT.xlsx
            Range("Q" & RowNum).FormulaR1C1 = "= IF(ISNA(VLOOKUP(RC[-4],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!R1:R1048576,3,0)), ""NOT INDICATED"",(VLOOKUP(RC[-4],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!R1:R1048576,3,0)))"
        
        End If
        
            'Fill only the "NOT INDICATED" Cells
            'Don't use Autofill as it will overwrite every row
            Range(Cells(RowNum, "P"), Cells(RowNum, "Q")).Select
            Selection.Copy
            Selection.PasteSpecial Paste:=xlPasteValues
        
        
        'Highlight the cells - "NOT INDICATED" in 'red' means not found in MissingUserNameDept file
        If UCase(Cells(RowNum, 16)) Like "*NOT INDICATED*" Then
            Cells(RowNum, 16).Interior.Color = RGB(255, 0, 0)
        End If
        
        If UCase(Cells(RowNum, 17)) Like "*NOT INDICATED*" Then
            Cells(RowNum, 17).Interior.Color = RGB(255, 0, 0)
        End If
    Next
                   
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    
    
End Sub
 
You could get code to open the other workbook when this workbook is opened?

With something like

Rich (BB code):
Private Sub Workbook_Open()
Workbooks.Open Filename:=ThisWorkbook.Path & "\MISSINGUSERNAMEDEPT.xlsx"
End Sub

in the code for 'ThisWorkbook'
 
Upvote 0
You could get code to open the other workbook when this workbook is opened?

With something like

Rich (BB code):
Private Sub Workbook_Open()
Workbooks.Open Filename:=ThisWorkbook.Path & "\MISSINGUSERNAMEDEPT.xlsx"
End Sub

in the code for 'ThisWorkbook'

Do i need to declare the workbook path ?
 
Upvote 0
yes, unless the 'MISSINGUSERNAMEDEPT.xlsx' file is in the same folder as the file with your code in. Then the above code will work.
 
Upvote 0

Forum statistics

Threads
1,226,824
Messages
6,193,164
Members
453,778
Latest member
RDJones45

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