Input Box Trouble

  • Thread starter Thread starter Ewing25
  • Start date Start date
E

Ewing25

I am trying to make it so that when a user inputs the amount of trips they
have taken, Excel automatically copys that amount of worksheets.

I made a Macro that copys the worksheets but im not sure how to integrate
that into an input box.

the copy sheet code:

Sheets("Individual Trip").Select
Sheets("Individual Trip").Copy After:=Sheets(3)

Thanks!
 
I am trying to make it so that when a user inputs the amount of trips they
have taken, Excel automatically copys that amount of worksheets.

I made a Macro that copys the worksheets but im not sure how to integrate
that into an input box.

the copy sheet code:

  Sheets("Individual Trip").Select
    Sheets("Individual Trip").Copy After:=Sheets(3)

Thanks!

Hi

Try this

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

Trips = InputBox("Enter no. of trips")
If Trips > 0 Then
'Sheets("Individual Trip").Select
For tr = 1 To Trips
Sheets("Individual Trip").Copy After:=Sheets(Sheets.Count)
Next
End If
End Sub

Regards,
Per
 
That worked great thanks!!

Per Jessen said:
Hi

Try this

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

Trips = InputBox("Enter no. of trips")
If Trips > 0 Then
'Sheets("Individual Trip").Select
For tr = 1 To Trips
Sheets("Individual Trip").Copy After:=Sheets(Sheets.Count)
Next
End If
End Sub

Regards,
Per
 
Okay it worked the first time i used it. But now its copying the code over to
the copyed worksheets and it will ask me again if i select the other tabs.
Can i get rid of that? Also if i press cancel it comes with an error "Runtime
error - 13, Type Mismatch"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top