Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Want to add a user defined selection

Hi, I am using a copy of Ron de Bruin's "Copy to Worksheets" macro. I would
like to enter a place for the user to define which worksheet to copy. The
number of sheets each month will vary and names will vary. Otherwise, works
great.

This is the current line of code:

'Name of the sheet with your data
Set ws1 = Sheets("Sheet1") '<<< Change


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Want to add a user defined selection

Sub marcia()
Set ws1 = Sheets(Application.InputBox(prompt:="enter sheetname:", Type:=2))
End Sub

--
Gary''s Student - gsnu200797


"marcia2026" wrote:

Hi, I am using a copy of Ron de Bruin's "Copy to Worksheets" macro. I would
like to enter a place for the user to define which worksheet to copy. The
number of sheets each month will vary and names will vary. Otherwise, works
great.

This is the current line of code:

'Name of the sheet with your data
Set ws1 = Sheets("Sheet1") '<<< Change


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Want to add a user defined selection

I would think replacing the indicated line with this would do what you
want...

'*************** START OF REPLACEMENT ***************
Do
strInput = InputBox("Some prompt for input")
If Len(strInput) = 0 Then
If StrPtr(strInput) = 0 Then
' User clicked Cancel Button, exit subroutine
Exit Sub
End If
Else
On Error Resume Next
Set ws1 = Sheets(strInput)
If Err.Number = 0 Then
Exit Do
Else
MsgBox """" & strInput & """ is not a valid Sheet Name!"
End If
End If
Loop
'*************** END OF REPLACEMENT ***************
'
' The subroutine code continues here
'

Don't forget to Dim the strInput variable as String.

Rick



"marcia2026" wrote in message
...
Hi, I am using a copy of Ron de Bruin's "Copy to Worksheets" macro. I
would
like to enter a place for the user to define which worksheet to copy. The
number of sheets each month will vary and names will vary. Otherwise,
works
great.

This is the current line of code:

'Name of the sheet with your data
Set ws1 = Sheets("Sheet1") '<<< Change



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Want to add a user defined selection

Thanks guys very much. Works great.

"marcia2026" wrote:

Hi, I am using a copy of Ron de Bruin's "Copy to Worksheets" macro. I would
like to enter a place for the user to define which worksheet to copy. The
number of sheets each month will vary and names will vary. Otherwise, works
great.

This is the current line of code:

'Name of the sheet with your data
Set ws1 = Sheets("Sheet1") '<<< Change


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
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
Workspace faux user-defined type not defined Chris S[_2_] Excel Programming 3 November 11th 04 05:51 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM
How do I convert a user defined selection into an array? TBA[_2_] Excel Programming 3 August 18th 03 12:51 AM


All times are GMT +1. The time now is 07:32 PM.

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"