VBA: Ignore Open File Dialog Box

donatepresent

New Member
Joined
Oct 4, 2017
Messages
21
Hi Experts,

I'm trying to paste the below code, but I want it to not popup the 'open file dialog box' because I have another line of code that copy & paste this code and that pop up the open file dialog box, so I do not want it to popup twice. Therefore, I need it to either ignore the first or second popup of the open file dialog box.

VBA Code:
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(HLOOKUP(R[-38]C,'[FileToOpen = Application.GetOpenFilename]Programs'!R6C4:R41C55,36,FALSE),"""")"

Full code:

VBA Code:
    With ActiveWorkbook.Sheets("Sheet2")
    Range("D44").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(HLOOKUP(R[-38]C,'[FileToOpen = Application.GetOpenFilename]Programs'!R6C4:R41C55,36,FALSE),"""")"
    End With

    Range("D44").Select
    Selection.Copy
    Range("D43").Select
    Selection.End(xlToRight).Select
    ActiveCell.Offset(1, 0).Activate
    Range(Selection, Selection.End(xlToLeft)).Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.Style = "Comma"

Thanks,
Ken
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
VBA Code:
    With ActiveWorkbook.Sheets("Sheet2")
      With .Range("D44", Cells(43, Columns.count).End(xlToLeft).Offset(1))
         .FormulaR1C1 = _
           "=IFERROR(HLOOKUP(R[-38]C,'[FileToOpen]Programs'!R6C4:R41C55,36,FALSE),"""")"
         .Style = "Comma"
      End With
    End With
 
Upvote 0
Solution
How about
VBA Code:
    With ActiveWorkbook.Sheets("Sheet2")
      With .Range("D44", Cells(43, Columns.count).End(xlToLeft).Offset(1))
         .FormulaR1C1 = _
           "=IFERROR(HLOOKUP(R[-38]C,'[FileToOpen]Programs'!R6C4:R41C55,36,FALSE),"""")"
         .Style = "Comma"
      End With
    End With

You are a saint! Thank you very much! :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

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