Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default looping problem



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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default looping problem

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!

"Ewing25" wrote:



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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default looping problem

Okay i changed it and its still giving me the same error.

"Mike H." wrote:

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!

"Ewing25" wrote:



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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default looping problem

Change
If Trips 1 Then

To

If Trips < "" And Trips < 0 Then




"Ewing25" wrote:

Okay i changed it and its still giving me the same error.

"Mike H." wrote:

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!

"Ewing25" wrote:



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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default looping problem

works perfectly thanks!

"Mike H." wrote:

Change
If Trips 1 Then

To

If Trips < "" And Trips < 0 Then




"Ewing25" wrote:

Okay i changed it and its still giving me the same error.

"Mike H." wrote:

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!

"Ewing25" wrote:



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





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
Looping problem rpw Excel Programming 0 May 23rd 07 10:57 PM
Looping Problem GregR Excel Programming 0 September 26th 06 04:29 PM
Looping problem........ Steve Jones Excel Programming 1 September 22nd 06 04:31 PM
Looping Problem Paul Black Excel Programming 3 September 17th 05 09:59 AM
Looping Problem Todd Huttenstine[_3_] Excel Programming 5 January 25th 04 12:51 AM


All times are GMT +1. The time now is 06:06 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"