Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Passing Strings from UserForm to Module

Using VBA, I want to collect a range from the user with a UserForm, and then pass the range string to a subroutine in a module. I can pass numbers in this fashion, but I am unsuccessful passing strings. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Passing Strings from UserForm to Module

Rather than suggest a way, why don't you tell us how you pass numbers, as
the technique for strings should be similar.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Kauffman" wrote in message
...
Using VBA, I want to collect a range from the user with a UserForm, and

then pass the range string to a subroutine in a module. I can pass numbers
in this fashion, but I am unsuccessful passing strings. Any suggestions?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Passing Strings from UserForm to Module

John,

Dimension a string as a public variable at the top of a codemodule:

Option Explicit
Public myStr As String

Sub TryNow()
Load UserForm1
UserForm1.Show
MsgBox myStr
Range(myStr).Select
End Sub

Put a RefEdit box on your userform - which is the best way to select a
range, and then use something like this with a commandbutton:

Private Sub CommandButton1_Click()
myStr = UserForm1.RefEdit1.Text
UserForm1.Hide
End Sub

HTH,
Bernie
MS Excel MVP

"John Kauffman" wrote in message
...
Using VBA, I want to collect a range from the user with a UserForm, and

then pass the range string to a subroutine in a module. I can pass numbers
in this fashion, but I am unsuccessful passing strings. Any suggestions?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Passing Strings from UserForm to Module

Sub Main()
Dim sStr as String
sStr = "A1:B30"
mysub sStr
End Sub

Sub MySub(sStr1 as String)
msgbox Range(sStr1).Address(External:=True)
End Sub

--
Regards,
Tom Ogilvy

"John Kauffman" wrote in message
...
Using VBA, I want to collect a range from the user with a UserForm, and

then pass the range string to a subroutine in a module. I can pass numbers
in this fashion, but I am unsuccessful passing strings. Any suggestions?


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
Passing array of strings from DLL function to VBA Jag Man Excel Programming 0 January 12th 04 10:09 PM
passing strings vba man Excel Programming 0 December 21st 03 07:12 PM
passing strings pabs[_7_] Excel Programming 2 December 19th 03 06:25 PM
Passing variables from module to userform Chris Dunigan Excel Programming 4 November 26th 03 09:37 AM
passing strings Sirron Excel Programming 2 August 27th 03 04:33 PM


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