eric86vabeach
New Member
- Joined
- Jan 29, 2014
- Messages
- 23
im working on a userform that updatas the data if the person fist and last name is in on the sheet in column B&C.
so what i would like to do is if the frist and last name match then it updates the row with textbox3,textbox4 ...ect
then it textbox5 adds
the "new info" the frist blank column after column "k"
then
then it textbox6 adds
the "new info" the next blank column after column "k"
and so till textbox8
---------------------------------------------
this is what i have so far
-----------------------------------------
Private Sub CommandButton1_Click()
Dim dataRow As Long
On Error Resume Next 'in case the data is new
'DataRow
dataRow = WorksheetFunction.Match(TextBox1.Value, TextBox2, .Range("B:B"))
'add a new row if not found in current data
If dataRow = 0 Then dataRow = .Range("B" & .Rows.Count).End(xlUp).Row + 1
'Export Data to worksheet
.Cells(dataRow, 1).Value = Date
.Cells(dataRow, 2).Value = TextBox1.Value 'frist name
.Cells(dataRow, 3).Value = TextBox2.Value 'last name
.Cells(dataRow, 4).Value = TextBox3.Value 'phone# ---- update if not same
.Cells(dataRow, 5).Value = TextBox4.Value 'email ---- update if not same
.Cells(dataRow, 6).Value = TextBox5.Value 'new info ---- update if not same
.Cells(dataRow, 7).Value = TextBox6.Value 'new info ---- update if not same
.Cells(dataRow, 8).Value = TextBox7.Value 'new info ---- update if not same
.Cells(dataRow, 9).Value = TextBox8.Value 'new info ---- update if not same
End With
End Sub
--------------------------------------------------------------------------------------------------
any tips or links would help me out
thanks for your time and reading this
-eric-
so what i would like to do is if the frist and last name match then it updates the row with textbox3,textbox4 ...ect
then it textbox5 adds
the "new info" the frist blank column after column "k"
then
then it textbox6 adds
the "new info" the next blank column after column "k"
and so till textbox8
---------------------------------------------
this is what i have so far
-----------------------------------------
Private Sub CommandButton1_Click()
Dim dataRow As Long
On Error Resume Next 'in case the data is new
'DataRow
dataRow = WorksheetFunction.Match(TextBox1.Value, TextBox2, .Range("B:B"))
'add a new row if not found in current data
If dataRow = 0 Then dataRow = .Range("B" & .Rows.Count).End(xlUp).Row + 1
'Export Data to worksheet
.Cells(dataRow, 1).Value = Date
.Cells(dataRow, 2).Value = TextBox1.Value 'frist name
.Cells(dataRow, 3).Value = TextBox2.Value 'last name
.Cells(dataRow, 4).Value = TextBox3.Value 'phone# ---- update if not same
.Cells(dataRow, 5).Value = TextBox4.Value 'email ---- update if not same
.Cells(dataRow, 6).Value = TextBox5.Value 'new info ---- update if not same
.Cells(dataRow, 7).Value = TextBox6.Value 'new info ---- update if not same
.Cells(dataRow, 8).Value = TextBox7.Value 'new info ---- update if not same
.Cells(dataRow, 9).Value = TextBox8.Value 'new info ---- update if not same
End With
End Sub
--------------------------------------------------------------------------------------------------
any tips or links would help me out
thanks for your time and reading this
-eric-