Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Create a public variable

Below is my UserForm_Initialize code. What I'm wondering is, is it possible
to declare a Public Variable if rng(1, 7).value is "Yes"?

I would call the Variable Cleared and then during my exit routine
(clicking the Finished Button) I would need a statement that said if Cleared
is true then exit sub.



Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Value = rng(1, 1) 'Date
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")
TextBox2.Value = rng(1, 2) 'Check Number
TextBox3.Value = rng(1, 3) 'Check Amount
TextBox3.Value = Format(TextBox3.Value, "currency")
TextBox4.Value = rng(1, 4) 'Paid To
TextBox5.Value = rng(1, 5) 'Explination

If rng(1, 7).Value = "Yes" Then
OptionButton1.Value = True
End If

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Create a public variable


You need to put the public statement in a module outside any function or
sub. Like this


Public Joel1

Sub Test
Userform1.Show
end Test


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=157596

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Create a public variable

This should help. If this helps please click "YES" below.

If rng(1, 7).Value = "Yes" Then
Public Cleared As Boolean
Cleared = True
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub
--
Cheers,
Ryan


"ordnance1" wrote:

Below is my UserForm_Initialize code. What I'm wondering is, is it possible
to declare a Public Variable if rng(1, 7).value is "Yes"?

I would call the Variable Cleared and then during my exit routine
(clicking the Finished Button) I would need a statement that said if Cleared
is true then exit sub.



Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Value = rng(1, 1) 'Date
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")
TextBox2.Value = rng(1, 2) 'Check Number
TextBox3.Value = rng(1, 3) 'Check Amount
TextBox3.Value = Format(TextBox3.Value, "currency")
TextBox4.Value = rng(1, 4) 'Paid To
TextBox5.Value = rng(1, 5) 'Explination

If rng(1, 7).Value = "Yes" Then
OptionButton1.Value = True
End If

End Sub

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Create a public variable

Did you actually try that?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Ryan H" wrote in message
...
This should help. If this helps please click "YES" below.

If rng(1, 7).Value = "Yes" Then
Public Cleared As Boolean
Cleared = True
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub
--
Cheers,
Ryan


"ordnance1" wrote:

Below is my UserForm_Initialize code. What I'm wondering is, is it
possible
to declare a Public Variable if rng(1, 7).value is "Yes"?

I would call the Variable Cleared and then during my exit routine
(clicking the Finished Button) I would need a statement that said if
Cleared
is true then exit sub.



Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Value = rng(1, 1) 'Date
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")
TextBox2.Value = rng(1, 2) 'Check Number
TextBox3.Value = rng(1, 3) 'Check Amount
TextBox3.Value = Format(TextBox3.Value, "currency")
TextBox4.Value = rng(1, 4) 'Paid To
TextBox5.Value = rng(1, 5) 'Explination

If rng(1, 7).Value = "Yes" Then
OptionButton1.Value = True
End If

End Sub

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Create a public variable

No, Bob. I didn't. Thanks for the correction. It should be.

'in standard module
Public Cleared As Boolean

If rng(1, 7).Value = "Yes" Then
Cleared = True
Else
Cleared = False
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub

--
Cheers,
Ryan


"Bob Phillips" wrote:

Did you actually try that?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Ryan H" wrote in message
...
This should help. If this helps please click "YES" below.

If rng(1, 7).Value = "Yes" Then
Public Cleared As Boolean
Cleared = True
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub
--
Cheers,
Ryan


"ordnance1" wrote:

Below is my UserForm_Initialize code. What I'm wondering is, is it
possible
to declare a Public Variable if rng(1, 7).value is "Yes"?

I would call the Variable Cleared and then during my exit routine
(clicking the Finished Button) I would need a statement that said if
Cleared
is true then exit sub.



Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Value = rng(1, 1) 'Date
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")
TextBox2.Value = rng(1, 2) 'Check Number
TextBox3.Value = rng(1, 3) 'Check Amount
TextBox3.Value = Format(TextBox3.Value, "currency")
TextBox4.Value = rng(1, 4) 'Paid To
TextBox5.Value = rng(1, 5) 'Explination

If rng(1, 7).Value = "Yes" Then
OptionButton1.Value = True
End If

End Sub

.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Create a public variable

If rng(1, 7).Value = "Yes" Then
Cleared = True
Else
Cleared = False
End If


Or, more concisely, replace the above with this single line of code...

Cleared = rng(1, 7).Value = "Yes"

--
Rick (MVP - Excel)


"Ryan H" wrote in message
...
No, Bob. I didn't. Thanks for the correction. It should be.

'in standard module
Public Cleared As Boolean

If rng(1, 7).Value = "Yes" Then
Cleared = True
Else
Cleared = False
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub

--
Cheers,
Ryan


"Bob Phillips" wrote:

Did you actually try that?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Ryan H" wrote in message
...
This should help. If this helps please click "YES" below.

If rng(1, 7).Value = "Yes" Then
Public Cleared As Boolean
Cleared = True
End If

Sub FinishedButton_Click()
If Cleared Then Exit Sub
End Sub
--
Cheers,
Ryan


"ordnance1" wrote:

Below is my UserForm_Initialize code. What I'm wondering is, is it
possible
to declare a Public Variable if rng(1, 7).value is "Yes"?

I would call the Variable Cleared and then during my exit routine
(clicking the Finished Button) I would need a statement that said if
Cleared
is true then exit sub.



Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Value = rng(1, 1) 'Date
TextBox1.Text = Format(TextBox1.Text, "mm/dd/yyyy")
TextBox2.Value = rng(1, 2) 'Check Number
TextBox3.Value = rng(1, 3) 'Check Amount
TextBox3.Value = Format(TextBox3.Value, "currency")
TextBox4.Value = rng(1, 4) 'Paid To
TextBox5.Value = rng(1, 5) 'Explination

If rng(1, 7).Value = "Yes" Then
OptionButton1.Value = True
End If

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
Public variable (or Public Const?) Brettjg Excel Programming 14 April 23rd 09 11:30 PM
Public variable (or Public Const?) Tim Williams[_2_] Excel Programming 0 April 23rd 09 06:33 AM
Public variable Eric[_35_] Excel Programming 7 March 18th 07 06:54 AM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


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