Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default question on scope of a global variable

I have a user form. it loads a combo box , with a list of patients,
1 of the options is print a single sheet. I don't know how to save
the selected value in a global and get that to the module from the
userform. I tried a public global varible in the userform. I tried
accessing this from the module like
UserForm1.g_fnameLast and I don't get the value, what am I doing
wrong? the asterisks is where I'm not getting the value.

tia,

-----combo box event in userform1----------
Option Explicit
Public g_rng As Range
Public g_fNameLName As String

Public Sub ComboBox2_change()

Select Case ComboBox2.Value
Case Is = "All"
prntAllPatientsShts
Case Is = "Exit"

'do nothing

Case Else

g_fNameLName = UserForm1.ComboBox2.Value
prntSinglePatientSht
SingleMonths
End Select

Unload Me
Me.ComboBox2.Clear
End Sub


-------code where I'm trying to access g_fnamelname-----------------

Sub CpySinglePatientSht()
Dim wb As Workbook
Dim ws As Worksheet
Dim Lname As String
Dim sStr As String


Set wb = ThisWorkbook

wb.Sheets(2).Copy befo=wb.Sheets(2)
'copies the control worksheet and puts the copied sheet in front
of it
Set ws = wb.Sheets(2)
sStr = UserForm1.g_fNameLName *********
Lname = Mid(sStr, InStr(1, sStr, " ") + 1)
'parses the FName and LName concatenation into _
just the Lname and renames worksheet
ws.Name = Lname
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
variable scope question in user-defined function Pertti Excel Programming 2 October 17th 06 07:11 PM
Question about variable scope RB Smissaert Excel Programming 0 March 2nd 05 01:15 PM
I Need VBA Assistance for global variable question Brent E Excel Discussion (Misc queries) 1 March 1st 05 08:46 PM
Variable scope question w/combo-box, 2ND try Tim Coddington Excel Programming 2 December 20th 03 04:07 AM
Variable scope question w/combo-box Tim Coddington Excel Programming 4 December 17th 03 02:38 AM


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