ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reference to another sheet not in wkbk brings up dialog box (https://www.excelbanter.com/excel-programming/405539-reference-another-sheet-not-wkbk-brings-up-dialog-box.html)

Valerie

reference to another sheet not in wkbk brings up dialog box
 
I have a macro that writes a formula referencing another sheet in the
workbook. When this sheet isn't in the workbook, Excel opens the dialog box
to find the sheet and repeats for every line that contains the reference. I
would like to add something around the section referring to another sheet to
bypass that section if the sheet is not in the workbook. Is this possible?

Bernie Deitrick

reference to another sheet not in wkbk brings up dialog box
 
Valeire

Dim ShtName As String
'Other Code

On Error Goto NoSheet:
ShtName = Worksheets("Sheet that may not be there").Name
'Code for formula referencing
NoSheet:

'Finish up code

HTH,
Bernie
MS Excel MVP


"Valerie" wrote in message
...
I have a macro that writes a formula referencing another sheet in the
workbook. When this sheet isn't in the workbook, Excel opens the dialog box
to find the sheet and repeats for every line that contains the reference. I
would like to add something around the section referring to another sheet to
bypass that section if the sheet is not in the workbook. Is this possible?




Valerie

reference to another sheet not in wkbk brings up dialog box
 
Perfect!! Thanks so much!

"Bernie Deitrick" wrote:

Valeire

Dim ShtName As String
'Other Code

On Error Goto NoSheet:
ShtName = Worksheets("Sheet that may not be there").Name
'Code for formula referencing
NoSheet:

'Finish up code

HTH,
Bernie
MS Excel MVP


"Valerie" wrote in message
...
I have a macro that writes a formula referencing another sheet in the
workbook. When this sheet isn't in the workbook, Excel opens the dialog box
to find the sheet and repeats for every line that contains the reference. I
would like to add something around the section referring to another sheet to
bypass that section if the sheet is not in the workbook. Is this possible?






All times are GMT +1. The time now is 05:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com