VBA multiple textbox to cell value

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
623
Office Version
  1. 2016
Platform
  1. Windows
Just need a better way to input 112 textboxes from column D - DN

instead of using this below for 112 textboxes
VBA Code:
         Cells(Rg.Row, "D") = TextBox3
         Cells(Rg.Row, "F") = TextBox4
         Cells(Rg.Row, "E") = TextBox5
         Cells(Rg.Row, "G") = TextBox6

VBA Code:
Private Sub CommandButton1_Click()
Dim EmpID$, dDate$, Mth$, Yr$, Rg, Dd As Range, EmpCells&, i&, x&, Emp1Name As String, Emp2Name As String
EmpID = TextBox1.Value

If TextBox1.Value = "" Or TextBox2.Value = "" Then
   MsgBox "PLEASE ENTER THE EMPLOYEE NUMBER AND EFFECTIVE DATE", vbExclamation: Exit Sub
End If

If Not IsNumeric(EmpID) Then
MsgBox "INVALID EMPLOYEE NUMBER ENTER NUMBER WITHOUT THE E", vbExclamation: Exit Sub
End If

With Sheets("PERMANENT BID")
         Set Rg = .Columns(5).Find(EmpID, lookat:=xlWhole)
         If Rg Is Nothing Then
            MsgBox "EMPLOYEE NUMBER DOES NOT EXIST PLEASE TRY AGAIN", vbExclamation: Exit Sub
         Else
         Cells(Rg.Row, "D") = TextBox3
         Cells(Rg.Row, "F") = TextBox4
         Cells(Rg.Row, "E") = TextBox5
         Cells(Rg.Row, "G") = TextBox6
End Sub


is there a way to use a shortcut like below
VBA Code:
 'Set Rg = (.Cells(Rg.Row, "D").Resize(, 112))
 
Thanks 6String that works perfect. I really appreciate your help
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,213,507
Messages
6,114,029
Members
448,543
Latest member
MartinLarkin

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