input from vba user form

dgehlod

New Member
Joined
Nov 14, 2014
Messages
10
hi i am new to vba i want to Update cells via a user form. user enter data in form and update in some cells like c5, c6, d5, d6, e6. e7.

one more thing i want to show some data from the sheet on a user form. please help me...

below given is code for 1st user form.

Code:
Option ExplicitPrivate Sub int_cal1_Click()
Worksheets("Non-Deduction").Activate
Range("A5").Select
       
       'Date
          ActiveCell.Offset(0, 3).Range("A5").Select
          Selection.Value = DD1.Text
        ActiveCell.Offset(1, 3).Range("A5").Select
         Selection.Value = DD2.Text
       
       'Month
          ActiveCell.Offset(0, 4).Range("D5").Select
          Selection.Value = MM1.Text
        ActiveCell.Offset(1, 4).Range("D6").Select
         Selection.Value = MM2.Text
       
       'Year
          ActiveCell.Offset(0, 5).Range("E5").Select
          Selection.Value = YYYY1.Text
        ActiveCell.Offset(1, 5).Range("E6").Select
         Selection.Value = YYYY2.Text
              
       'TDS Amount
         ActiveCell.Offset(3, 3).Range("C7").Select
          Selection.Value = TDSAMT.Text
       'TDS Rate
       ActiveCell.Offset(5, 3).Range("C9").Select
          Selection.Value = TDSRATE.Text
Me.DD1.SetFocus
Me.DD2.SetFocus
Me.MM1.SetFocus
Me.MM2.SetFocus
Me.YYYY1.SetFocus
Me.YYYY2.SetFocus
Me.TDSAMT.SetFocus
Me.TDSRATE.SetFocus
        Non_deduct.Hide
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, you have a few problems here so ill try step by step. I presume int_cal1 is a button on your worksheet? For the code for that you just need:

Code:
Private Sub int_cal1_Click()

Non_deduct.Show

End Sub

Then your userform is going to need a commandbutton. Then double click the commandbutton in vba design mode an insert this. This gives you the type of syntax you need so you can add others.

Code:
Option Explicit
Private Sub CommandButton1_Click()
With Worksheets("Non-Deduction")
       'Date
        .Range("A5").Offset(0, 3) = DD1.Text
        .Range("A5").Offset(1, 3) = DD2.Text
End With
Me.TDSRATE.SetFocus
non_deduct.Hide
End Sub

There is no point setting focus lots of times as each one overrides the last.

Any other help just ask.
 
Upvote 0
Hi, you have a few problems here so ill try step by step. I presume int_cal1 is a button on your worksheet? For the code for that you just need:

Code:
Private Sub int_cal1_Click()

Non_deduct.Show

End Sub

Then your userform is going to need a commandbutton. Then double click the commandbutton in vba design mode an insert this. This gives you the type of syntax you need so you can add others.

Code:
Option Explicit
Private Sub CommandButton1_Click()
With Worksheets("Non-Deduction")
       'Date
        .Range("A5").Offset(0, 3) = DD1.Text
        .Range("A5").Offset(1, 3) = DD2.Text
End With
Me.TDSRATE.SetFocus
non_deduct.Hide
End Sub

There is no point setting focus lots of times as each one overrides the last.

Any other help just ask.

Thanks For Reply :)
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

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