LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Error Trap Via Message

Hello All:
I have this code that creates tabs from a list, my problem is that I
want to add to it, so it would prevent creating tab if the name already
exist and give a message, can anybody help me
---------------------------------------------------------
Private Sub CommandButton3_Click()
' Declair Variables
Dim iLastRow As Long, i As Long, sh As Worksheet, LastCell As Range
Dim Rng As Range, cell As Range, WS As Worksheet

' Start Create Student Tab From List in Column A Starting A2
With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 2 Step -1
.Hyperlinks.Add Anchor:=Cells(i, "A"), _
Address:="", _
SubAddress:="'" & Cells(i, "A").Value &
"'!A1", _
TextToDisplay:=Cells(i, "A").Value
Next i
End With
'End Create Tab

' Start Creating Link From The List in Column A
' to The Student Tabs Starting FromCell A2
Set WS = ActiveSheet
Set LastCell = WS.Cells(Rows.Count, "A").End(xlUp)
Set Rng = WS.Range("A2", LastCell)

For Each cell In Rng
If Not IsEmpty(cell) Then
Sheets("Template").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = cell.Value
End If
Next
' End Creating Link

' Start Returning to Roster Tab
MakeVisible
Sheets("Template").Visible = False
Sheets("Template").Move Befo=Sheets(2)
Sheets("Roster").Select
Range("D2").Select
' Start Inserting formula for Transfering data to Roster
' module driven code
InsertInfoTransferFormula
CopyFormula
' End Inserting Formula For Transfering data to Roster
' Landing on Cell
Range("C1").Select
End Sub
----------------------------------------------------------------

 
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
How to error trap "... cannot find the data..." message? [email protected] Excel Discussion (Misc queries) 4 August 29th 08 02:57 AM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Trap Kirk P. Excel Programming 2 September 8th 05 09:51 PM
Error Trap TEB2 Excel Programming 2 March 15th 05 05:34 PM
How to trap the error message "Remote Data not accessible"? rghpvf Excel Programming 0 January 7th 04 05:40 PM


All times are GMT +1. The time now is 04:56 PM.

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

About Us

"It's about Microsoft Excel"