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
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,529
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

donatepresent

New Member
Joined
Oct 4, 2017
Messages
21
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! :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,529
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,554
Messages
5,625,474
Members
416,109
Latest member
TripleA00123

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
Top