Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default If sheet not created show a message

Hi all

I have a workbook with multiple sheets including one that is generated by
the user (via a button/macro).

I need a code that look for a sheet that "contains" MBA in it's name (it may
contain other words in the sheet name).

If the worksheet is not found then the message "Create MBA first" must
appear, stopping the macro. The user then should click on an OK button, and
fix the problem before re-running the macro.

Help with this would be greatly appreciated.
--
BeSmart



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default If sheet not created show a message

Here's the code to loop through the sheets to check whether the name
exists or not.
Sub CheckIfSheetNameExists(ByVal strCrit As String)
'
Dim CurSheet As Worksheet
Dim NameExists As Boolean

NameExists = False
For Each CurSheet In Sheets
If InStr(1, CurSheet.Name, strCrit) Then
NameExists = True
End If
Next CurSheet
If Not NameExists Then
MsgBox "Name does not exist. please fix"
Exit Sub
End If
End Sub

here's the code to test the procedure :
Sub test()
CheckIfSheetNameExists ("ExcelPragma.com")
End Sub

HTH

Fadi
www.chalouhis.com/XLBLOG

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default If sheet not created show a message

Why not just create it if it doesn't exist?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"BeSmart" wrote in message
...
Hi all

I have a workbook with multiple sheets including one that is generated by
the user (via a button/macro).

I need a code that look for a sheet that "contains" MBA in it's name (it

may
contain other words in the sheet name).

If the worksheet is not found then the message "Create MBA first" must
appear, stopping the macro. The user then should click on an OK button,

and
fix the problem before re-running the macro.

Help with this would be greatly appreciated.
--
BeSmart





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default If sheet not created show a message

Hi Bob
I wouldn't ask the question if it was that simple....

The user has to follow a process and they forget to do steps - therefore I
have to build in checks.

They work on the spreadsheet, then create a second worksheet called MBA and
then they run an extraction macro.... They forget to create the MBA and they
get debugging errors - hence my question on how I can incorporate a check and
message to see if they're done it and remind them to do so automatically.

A Big thanks to Fadi for your help.
BeSmart

"Bob Phillips" wrote:

Why not just create it if it doesn't exist?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"BeSmart" wrote in message
...
Hi all

I have a workbook with multiple sheets including one that is generated by
the user (via a button/macro).

I need a code that look for a sheet that "contains" MBA in it's name (it

may
contain other words in the sheet name).

If the worksheet is not found then the message "Create MBA first" must
appear, stopping the macro. The user then should click on an OK button,

and
fix the problem before re-running the macro.

Help with this would be greatly appreciated.
--
BeSmart






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Charts created show up different on other computers Angie Charts and Charting in Excel 0 January 19th 10 05:05 PM
Excel charts created don't show when e-mailed mainewayne Charts and Charting in Excel 6 July 29th 09 04:34 PM
Error message - PivotTable will not fit on sheet. Show as much as Donna W Excel Worksheet Functions 2 June 27th 07 04:20 AM
Is there a way to not show the 'date created' on Excel files? dan Excel Discussion (Misc queries) 1 April 11th 07 02:03 PM
A chart needs to be created to show names and $ amounts 400-6K ojpop Charts and Charting in Excel 1 November 12th 05 02:05 AM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"