VBA Fill Textbox from Cell

ksm283

New Member
Joined
Nov 11, 2010
Messages
6
Hi there,

I'm currently designing a check-in program for my organization what will do three things:

1. The user will put their ID# into a form and click "submit"
2. VBA code places the ID number in the first available cell of the first available row on Worksheet1. The next 6 cells in that row run Vlookups to access data from the master participant sheet (Worksheet2)
3. VBA code runs an IF statement to see if the participant raised enough money, and then opens either an Accepted or Denied form

What I want to do is have the textboxes on the Accepted form display the information from the 6 vlookup cells (ie, have all that information put FROM the cell TO the textboxes on the form).

This is a snippet of the code I have for the first portion of the process, which places the number from the textbox into the first available row:

Private Sub Submit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("SignIn")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

Can I somehow manipulate this to have it find the last filled row (maybe by making the 1 a -1)? And then how do I get it to take the information from that row and place it into the right textboxes?

Thanks,
Sean
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Thanks! Now how would I code it to make it take information from a cell in that row, and put it into a textbox on my form? I've tried different variations of this code, but to no avail:

Set Me.txtName.Value = ws.Cells(iRow, 2).Value

I've tried removing and replacing the 'Set' and switching the order that these come in...any thoughts?
 
Upvote 0
Change the Set to Let and you should be in business.
Set is for objects.
Let (a default not usually expressed) is for values.
 
Upvote 0
...still nothing. Here's my current code:

Private Sub ShowInfo_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("SignIn")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp)

'put cell contents into form textboxes
Let Me.txtName.Value = ws.Cells(iRow, 2).Value

End Sub

For some reason, it giving me error code 1004, and I can't quite seem to figure out what's wrong.
 
Upvote 0
Rich (BB code):
iRow = ws.Cells(Rows.Count, 1).End(xlUp)
This line is looking at the cell and setting iRow to that cell's (default) property .Value. (From the error, I suspect that that value may be 0.)
Try replacing that line with
Rich (BB code):
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
 
Upvote 0

Forum statistics

Threads
1,215,360
Messages
6,124,489
Members
449,166
Latest member
hokjock

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