Last Value into Textbox

perku

New Member
Joined
Aug 18, 2016
Messages
9
Please help!!

I have a userform for data entry and i want the textbox3 on this userform to display the last entry (an 8 digit code) in column E when the commandbutton is pressed to enter the data.
i am using the below code and cannot get it to work.

TextBox3.Value = Worksheets("Sheet1").Range("E1").End(xlDown).Value

Using excel 2013

Ryan
 
Have you tried it after I edited to remove the final ".Address" on that line?
The code as it currently is should be put where you set the values of Textbox3 thru 8
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
looks fine and i didn't change the default name of the worksheet. Is there a way i can post the spread sheet itself for you to look at?
 
Upvote 0
Try changing Sheets("Sheet1") to Sheet1.
 
Upvote 0
Still getting the error on the line in red.


Private Sub CommandButton1_Click()
If Len(TextBox1.Value) < 33 Then
MsgBox "Invalid Product Barcode"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
Else
If Len(TextBox2.Value) < 5 Then
MsgBox "Invalid Location Barcode"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
Else
If Len(TextBox2.Value) > 5 Then
MsgBox "Invalid Location Barcode"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
Else
Dim LastRow As Object


Set LastRow = Sheet1.Range("a65536").End(xlUp)


LastRow.Offset(1, 0).Value = TextBox1.Text
LastRow.Offset(1, 1).Value = TextBox2.Text

TextBox1.Text = ""
TextBox2.Text = ""
With Sheet1.Range("E:E")
With .Find("?*", after:=.Cells(1, 1), LookIn:=xlValue, lookat:=xlWhole, searchdirection:=xlPrevious)
TextBox3.Text = .Value
TextBox4.Text = .Offset(0, 2).Value
TextBox5.Text = .Offset(0, 3).Value
TextBox6.Text = .Offset(0, 1).Value
TextBox7.Text = .Offset(0, 5).Value
TextBox8.Text = .Offset(0, 4).Value
End With
End With
TextBox1.SetFocus


End If
End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

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