Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / April 2008

Tip: Looking for answers? Try searching our database.

looping problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ewing25 - 29 Apr 2008 13:38 GMT
When i click cancel it comes up with an error "Run time error'13', type
mismatch"

Here is my code so far

Private Sub Worksheet_Activate()
Call TripsCopy
End Sub

Sub TripsCopy()
Dim Trips As Integer
Dim tr As Integer

Trips = InputBox("Enter no. of trips")
If Trips > 1 Then
   'Sheets("Individual Trip").Select
   For tr = 1 To Trips
       Sheets("Individual Trip").Copy After:=Sheets(Sheets.Count)
   Next
End If
End Sub
Mike H. - 29 Apr 2008 13:50 GMT
When you select cancel trips has the value = "", which is not an integer.  
Change the declaration of trip to be:
Dim trips as variant

and this problem is solved!

> When i click cancel it comes up with an error "Run time error'13', type
> mismatch"
[quoted text clipped - 17 lines]
> End If
> End Sub
Ewing25 - 29 Apr 2008 13:58 GMT
Okay i changed it and its still giving me the same error.

> When you select cancel trips has the value = "", which is not an integer.  
> Change the declaration of trip to be:
[quoted text clipped - 23 lines]
> > End If
> > End Sub
Mike H. - 29 Apr 2008 14:04 GMT
Change
If Trips > 1 Then

To

If Trips <> "" And Trips <> 0 Then

> Okay i changed it and its still giving me the same error.
>
[quoted text clipped - 25 lines]
> > > End If
> > > End Sub
Ewing25 - 29 Apr 2008 14:08 GMT
works perfectly thanks!

> Change
> If Trips > 1 Then
[quoted text clipped - 32 lines]
> > > > End If
> > > > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.