Check Box in User Forms

deva123

New Member
Joined
Aug 19, 2014
Messages
5
Dear Friends,

I have Two Tax check box in the userforms. if tax is applicable and if "Yes" check box button is clicked, it should calculate the tax from the value of first, second and third text boxes in the userforms. Can any of you send VBA code to calculate the tax. Thanks in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You should be able to go into the userform and add a code to the checkbox button to run every time it is clicked. It would look something like this

Dim T1 as Double
T1 = TextBox1.value
Dim T2 as Double
T2 = TextBox2.value
Dim T3 as Double
T3 = TextBox3.value

If CheckBox1.value = True then
Tax = T1 + T2+ T3
end if

I am not sure what you are looking for in terms of output, but you could do a messagebox like
msgbox ("Your Tax is: " & Tax)
 
Last edited:
Upvote 0
Dear Friends,

I have four text boxes and one frame with two check boxes in it. these are in a userform.

in the first txtbox, I have Bill amount. on this amount tds has to be deducted
in the second txtbox I have advance amount. on which tds has to be deducted
in the third txtbox I have advance recovery. the tds has to be recovered.
the fourth txtbox result formula = txtbox1+txtbox2-txtbox3

If checkbox1 is clicked it should calculate the tds for a particular person. if checkbox2 is clicked, it should not.

in the above txtboxes are optional. one or two boxes may not have any value for a particular time. the VBA should ignore it and for the rest it should calculate the tds.

Help me with VBA code. Thanks in advance.
 
Upvote 0
I don't have time for a fully reply right now, but in general you need to identify all the "controls" in the form that you want to manipulate or read the values from. The basic structure would look something like: "UserForm1.Frame1.TextBox1.ActionYouWant". You can give all the controls custom names to make this easier and also if you put in the "." and start to type the name a drop down box should appear with all the possible options, which is helpful.

In terms of actions, if you only want to have something when a checkbox is checked then a good action is .Enabled. For example: "UserForm1.Frame1.TextBox1.Enabled = False" would make it so the user could not input anything into the text box when the userform is shown. This is a simple toggle of True/False.

Also to get the Value of a text box it is simply: "ValueYouWant = UserForm1.Frame1.TextBox1.Value"

With these actions and a little math, I would think that the coding you want should not be very difficult. You simply need to make it so it is triggered with a click of the checkbox you referenced and likely want to put it all in a conditional "if" statement to run if the checkbox value is TRUE.
 
Upvote 0
Dear Friends,

Thanks for your formation. Great is your information. I tried it and it was useful to me. It is working fine. but one thing is not working properly. there are two check boxes in a frame. If I click the first checkbox I am getting the result but the second check box is not working properly. Can you please advise me how to manipulate the checkboxes with VBA code. Thanks in advance.

Dear Mr. Mikerickson,

Tds is nothing but one kind of tax which has to be deducted when we make payment to all kind of service providers. Thanks.
 
Upvote 0
VBA Code for transfer of data to a new exce sheet based on condition

Dear friends,
I have <acronym title="visual basic for applications">VBA</acronym> code for transfer of data to another sheet. it works fine. but if the command button is pressed two times, it transfer the data for two times.

I need <acronym title="visual basic for applications">VBA</acronym> code which will transfer data to another sheet based on "date" (every Month end date) criteria,
if the criteria is met, it should replace the data.
if the criteria is not met, it should transfer the data to the first empty row.
totally either the data either should be replaced or transferred to empty row.

the code for transferring data to another sheet is attached herewith

Sub TransferToAnotherSheet_Click()
Dim smallrng As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
Dim SourceRange As Range, i As Integer

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'fill in the Source Sheet and range
Set SourceRange = Sheets("Master").Range("A9:V10500")

'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("FinalMaster")
Lr = DestSheet.Cells(Rows.Count, "A").End(xlUp).Row
i = 1

For Each smallrng In SourceRange.Areas

'We make DestRange the same size as smallrng and use the
'Value property to give DestRange the same values
With smallrng
Set DestRange = DestSheet.Cells(Lr + 1, i) _
.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = smallrng.Value
i = i + smallrng.Columns.Count
MsgBox "The data has been successfully copied."

Next smallrng

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub

I need a new <acronym title="visual basic for applications">VBA</acronym> code which will meet the both the criteria.

Thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,178
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top