PC Review


Reply
Thread Tools Rate Thread

Check Box Value

 
 
=?Utf-8?B?SGF6ZWw=?=
Guest
Posts: n/a
 
      25th Jan 2007
Hi All

This will be easy for you experts out there.

On a UserForm I have a Check Box that when I click on it I want it to add a
value of £1 to a Cell on a particular worksheet see code below.

Private Sub Add2_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Account")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 2) _
.End(xlUp).Offset(1, 0).Row



'copy the data to the database
ws.Cells(iRow, 1).Value = Me.Tb5.Value
ws.Cells(iRow, 2).Value = Me.Tb3.Value
ws.Cells(iRow, 4).Value = Me.Tb4.Value
'ws.Cells(iRow, 3).Value = Me.CHECKBOX4????????


'clear the data
Me.Tb3.Value = ""
Me.Tb4.Value = ""
Me.Tb5.Value = ""
Me.Tb6.Value = ""
Com3.Value = ""


End Sub

Where the ????? are what code would I add to make this work
--
Many thanks

hazel
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      25th Jan 2007
'ws.Cells(iRow, 3).Value = Me.CHECKBOX4????????
This line of code will not work since the Checkbox is boolean value, either
0 or 1, true or false. If you click the checkbox to add a value to
cells(iRow, 3), the value has to be specified in the execution of the
control's code like:
cells(iRow, 3) = 1 (Or "1" depending on your data type designation)
or alternatively:

Cells(iRow, 3) = Range("$P$3") (for example)

Where "P3" has the value of 1 entered. In other words the checkbox is only
a trigger and does not retain a Value.

"Hazel" wrote:

> Hi All
>
> This will be easy for you experts out there.
>
> On a UserForm I have a Check Box that when I click on it I want it to add a
> value of £1 to a Cell on a particular worksheet see code below.
>
> Private Sub Add2_Click()
>
> Dim iRow As Long
> Dim ws As Worksheet
> Set ws = Worksheets("Account")
>
> 'find first empty row in database
> iRow = ws.Cells(Rows.Count, 2) _
> .End(xlUp).Offset(1, 0).Row
>
>
>
> 'copy the data to the database
> ws.Cells(iRow, 1).Value = Me.Tb5.Value
> ws.Cells(iRow, 2).Value = Me.Tb3.Value
> ws.Cells(iRow, 4).Value = Me.Tb4.Value
> 'ws.Cells(iRow, 3).Value = Me.CHECKBOX4????????
>
>
> 'clear the data
> Me.Tb3.Value = ""
> Me.Tb4.Value = ""
> Me.Tb5.Value = ""
> Me.Tb6.Value = ""
> Com3.Value = ""
>
>
> End Sub
>
> Where the ????? are what code would I add to make this work
> --
> Many thanks
>
> hazel

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      26th Jan 2007
if me.Checkbox4.Value then
ws.Cells(iRow, 3).Value = ws.Cells(irow,3) + 1
End if


If you mean just enter a 1 (add not literally meaning to sum)


if me.Checkbox4.Value then
ws.Cells(iRow, 3).Value = 1
ws.Cells(iRow,3).Numberformat = "£ #"
End if



--
Regards,
Tom Ogilvy



"Hazel" <(E-Mail Removed)> wrote in message
newsD76B5D4-C8FF-4289-9861-(E-Mail Removed)...
> Hi All
>
> This will be easy for you experts out there.
>
> On a UserForm I have a Check Box that when I click on it I want it to add
> a
> value of £1 to a Cell on a particular worksheet see code below.
>
> Private Sub Add2_Click()
>
> Dim iRow As Long
> Dim ws As Worksheet
> Set ws = Worksheets("Account")
>
> 'find first empty row in database
> iRow = ws.Cells(Rows.Count, 2) _
> .End(xlUp).Offset(1, 0).Row
>
>
>
> 'copy the data to the database
> ws.Cells(iRow, 1).Value = Me.Tb5.Value
> ws.Cells(iRow, 2).Value = Me.Tb3.Value
> ws.Cells(iRow, 4).Value = Me.Tb4.Value
> 'ws.Cells(iRow, 3).Value = Me.CHECKBOX4????????
>
>
> 'clear the data
> Me.Tb3.Value = ""
> Me.Tb4.Value = ""
> Me.Tb5.Value = ""
> Me.Tb6.Value = ""
> Com3.Value = ""
>
>
> End Sub
>
> Where the ????? are what code would I add to make this work
> --
> Many thanks
>
> hazel



 
Reply With Quote
 
=?Utf-8?B?SGF6ZWw=?=
Guest
Posts: n/a
 
      26th Jan 2007
Hi Tom

Solved my little problem with the last snippet of code, much appreciated
--
Many thanks

hazel


"Tom Ogilvy" wrote:

> if me.Checkbox4.Value then
> ws.Cells(iRow, 3).Value = ws.Cells(irow,3) + 1
> End if
>
>
> If you mean just enter a 1 (add not literally meaning to sum)
>
>
> if me.Checkbox4.Value then
> ws.Cells(iRow, 3).Value = 1
> ws.Cells(iRow,3).Numberformat = "£ #"
> End if
>
>
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "Hazel" <(E-Mail Removed)> wrote in message
> newsD76B5D4-C8FF-4289-9861-(E-Mail Removed)...
> > Hi All
> >
> > This will be easy for you experts out there.
> >
> > On a UserForm I have a Check Box that when I click on it I want it to add
> > a
> > value of £1 to a Cell on a particular worksheet see code below.
> >
> > Private Sub Add2_Click()
> >
> > Dim iRow As Long
> > Dim ws As Worksheet
> > Set ws = Worksheets("Account")
> >
> > 'find first empty row in database
> > iRow = ws.Cells(Rows.Count, 2) _
> > .End(xlUp).Offset(1, 0).Row
> >
> >
> >
> > 'copy the data to the database
> > ws.Cells(iRow, 1).Value = Me.Tb5.Value
> > ws.Cells(iRow, 2).Value = Me.Tb3.Value
> > ws.Cells(iRow, 4).Value = Me.Tb4.Value
> > 'ws.Cells(iRow, 3).Value = Me.CHECKBOX4????????
> >
> >
> > 'clear the data
> > Me.Tb3.Value = ""
> > Me.Tb4.Value = ""
> > Me.Tb5.Value = ""
> > Me.Tb6.Value = ""
> > Com3.Value = ""
> >
> >
> > End Sub
> >
> > Where the ????? are what code would I add to make this work
> > --
> > Many thanks
> >
> > hazel

>
>
>

 
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
Spell check -- text marked skip spelling and grammar check =?Utf-8?B?RGF2aWQgQS4=?= Microsoft Word Document Management 8 9th Aug 2008 11:47 PM
Asp.net Treeview Clientscript - Auto Check Child Notes After Check Parent Node Sylvie Microsoft C# .NET 1 9th Oct 2007 02:25 PM
Treeview Clientscript - Auto Check Child Notes After Check Parent Node Sylvie Microsoft ASP .NET 1 9th Oct 2007 02:25 PM
In outlook get message "Spell check cannot check items...try agai =?Utf-8?B?am1yYW5jaG1hbg==?= Microsoft Outlook Discussion 1 28th Sep 2006 10:26 PM
Xp:Check Disk:Tools:Check Now:Both Options:reboot countdown does not complete? RAS Windows XP General 3 1st Feb 2005 06:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:45 PM.