+++Help me with a loop... I have no idea what code I need!

  • Thread starter Adeptus - ExcelForums.com
  • Start date
A

Adeptus - ExcelForums.com

I'm having a persistant problem with trying to code what I want.

What I have is a list of names(A2:A82), and a UserForm that lets me
include one of these names(textBox1). It also has 4 values
associated with the name.

WHen I click the command button, I want to have it find the name i've
included (textBox1) within the list of names (A2:A82)

Then I want it to past the 4 values across the next 4 colums in the
same row.

I think it'll be a loop, but I don't know how.

++++Here follows an example++++

so I have:

Ben
Mary
James
Billy
Bob
Rudy
Frank
Hanz

I input "Billy" into my form, and then have values 20, 5, 5 and 0 in
other text boxes.

when I click a button to enter the data, it will look down the list of
names, find that billy is in Row 4, then it will copy the 20 in the
next column, the 5 in the next column and the 0 in the last column.


I'm really frustrated with this, because it seems so straight forward
and I can't do it. I hate being new to something...
 
V

Vasant Nanavati

Sub CommandButton1_Click()
Dim i As Integer
For i = 2 To 82
If Cells(i, 1) = TextBox1 Then
Cells (i, 2) = TextBox2
Cells (i, 3) = TextBox3
Cells (i, 4) = TextBox4
Cells (i, 5) = TextBox5
End If
Next
End Sub

You could also use the Find method but the above will probably be easier for
you to understand and modify as needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top