Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VB: Loop till empty cell found

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I have a form that after filled out, adds an intern name and job skills to a worksheet called interns when a button is clicked. How can I have the data of the new intern entered into the next empty row? I'm thinking I need a loop that starts with the first row and then keeps going down until cell A1 is empty(does not have a name in it). Anyone know any code for this? Thanks in advance for the help.
 
two methods?:
1)
loop until first cell (assume column A) is empty

counter = 1
do until cells(counter, 1) = ""
counter=counter +1
loop
maxrows = counter -1
'use maxrows as index to new entry

2)
I would presume this would work...
maxrows = application.activesheet.usedrange.rows.count (this would return the # of rows, last used in the sheet)

the index for the next entry would be maxrows+1 obviously for the next line

hope this helps [yinyang] Tranpkp [pc2]
 
On your enter button click event:

lRow = sheets("Intern").range("a65536").end(xlup).row
Sheets("Intern").range("A" & lRow + 1).value = frmName.txtBoxName.text
Rgds
~Geoff~
 
Thank you both for the help. Geoff, the code you sent me was very efficient, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top