PC Review


Reply
Thread Tools Rate Thread

Create a public variable

 
 
ordnance1
Guest
Posts: n/a
 
      27th Nov 2009
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 With Quote
 
 
 
 
Ryan H
Guest
Posts: n/a
 
      27th Nov 2009
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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      27th Nov 2009
Did you actually try that?

--

HTH

Bob Phillips

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

"Ryan H" <(E-Mail Removed)> wrote in message
news:3F6E781B-BE13-4174-986A-(E-Mail Removed)...
> 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 With Quote
 
Ryan H
Guest
Posts: n/a
 
      27th Nov 2009
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" <(E-Mail Removed)> wrote in message
> news:3F6E781B-BE13-4174-986A-(E-Mail Removed)...
> > 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 With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      27th Nov 2009
> 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" <(E-Mail Removed)> wrote in message
news:39D1A15F-B859-4299-AD2B-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:3F6E781B-BE13-4174-986A-(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is anyone else using Public Modules with Public Variable in aspx Steve Mauldin Microsoft ASP .NET 5 26th Jan 2006 09:45 PM
Re: Public Variable or Public Property, which to use Kevin Spencer Microsoft ASP .NET 2 15th Sep 2004 01:46 PM
Re: Public Variable or Public Property, which to use Steve C. Orr [MVP, MCSD] Microsoft ASP .NET 0 13th Sep 2004 09:04 PM
public variable not public in class Laurence Nuttall Microsoft Dot NET 1 6th Mar 2004 04:20 AM
I would like to declare a Public Function or Public Variable Henro Microsoft Access Getting Started 2 1st Dec 2003 04:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:33 AM.