LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Prompt the user for an existing sheet

Thanks everyone for your responses!! I have learned a lot.

Jacob, yours was the easiest for me to understand and be able to put right
to work. Thank!
Arjen, I love the idea of the list, but tried as I may, I could not get it
to work. I'm sure it is due to my lack of understanding of VBA. I'm going
to continue to play with it and see if I can get it to work.

Thanks again!!
Shairal


"Bernie Deitrick" wrote:

Shairal,

You will need to include error checking:

Sub TryNow()
Dim DestSheet As Worksheet
Dim myName As String

On Error GoTo BadName

GetName:
myName = InputBox("Enter the name of the sheet you want to copy the data to.", _
"Enter Sheet Name")
myName = Worksheets(myName).Name
Set DestSheet = Sheets(myName)
MsgBox "Sheet """ & myName & """ does exist, so I will select it now."
DestSheet.Select
Exit Sub

BadName:
MsgBox "The sheet """ & myName & """ does not exist!"
Resume GetName
End Sub



HTH,
Bernie
MS Excel MVP


"Shairal" wrote in message
...
I will preface this with I have very little experience with VBA.

I have a little piece of code that copies data on a worksheet based on the
Range.AutoFilter method.

I now want to prompt my end user to enter the tab name of the worksheet that
he wants to copy the data to. I have found that I can set the name of the
sheet:
Set DestSheet = Sheets("SparkPlugs")
But I want the user to select the correct worksheet, instead of creating a
macro for each spreadsheet available.

I am able to prompt my user for the sheet name
DestSheet = InputBox("Enter the name of the sheet you want to copy the data
to.", _
"Enter Sheet Name")
But I don't know how to make the sheet equal the name provided in the
message box.

Thanks in advance for your assistance.




 
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
copying specific rows to an existing sheet, based on user paramete Carlee Excel Programming 1 April 2nd 07 12:38 PM
Prompt user to select a printer using a checkbox within a user Tom Ogilvy Excel Programming 0 January 10th 07 03:57 AM
Overwrite existing file without prompt Tom Ogilvy Excel Programming 0 September 17th 04 01:41 PM
Overwrite existing file without prompt Mark Excel Programming 0 September 17th 04 01:21 PM
Write over existing file with no Prompt DNewton Excel Programming 2 April 29th 04 06:54 PM


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