Most valuable professional
  • Hot Topics

Excel Help with workbook open code

Hello, I have this code that runs when I open my workbook. The problem I have is that I have a macro that updates my exchange rates and I prompt a message when I open the workbook asking if I want to update or not. The sheet where the exchange rates are in, is hidden, so I have to unhide the sheet when updating and hide it again when done. This works fine when I say yes to the update. If I say no, then I exit the sub and the exchange rate sheet is not hidden. How do I ensure that it is hidden when I press YES and NO? Here is the code: Private Sub Workbook_Open() Worksheets("Copied Prices").Cells.Delete Worksheets("Shock Compliance Information").Activate Worksheets("Prices").Range("B5").Value = "" Application.ScreenUpdating = False Sheets("Exchange rates").Visible = True If MsgBox("Internet connection needed to update exchange rates. Update now?", vbYesNo) = vbNo Then Exit Sub Sheets("Exchange rates").Select Selection.QueryTable.Refresh BackgroundQuery:=False Sheets("Exchange rates").Visible = False Range("A1").Select Application.ScreenUpdating = True End Sub

This question generated 12 answers. To proceed to the answers, click here.

This thread is current as of July 19, 2017.

For more resources for Microsoft Excel:

This article includes the following tags:

  • Excel
  • Microsoft Excel