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
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,110
Office Version
  1. 365
Platform
  1. Windows
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.
 

dgehlod

New Member
Joined
Nov 14, 2014
Messages
10
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 :)
 

Watch MrExcel Video

Forum statistics

Threads
1,108,860
Messages
5,525,241
Members
409,637
Latest member
LT TASL

This Week's Hot Topics

Top