Next Row

G

Guest

Hi All
I have been using the code below -- Cmd1 is a list box with 24 names what I
need is when I click on the next name on the list it will insert the data on
the next row down. At the moment I understand that its selecting a range "D2"
etc so every time I add it replaces the value in "D2"etc and not in "D3"
which is the next row --- I hope I've explained this OK

Private Sub Add6_Click()



startrownum = 2
endrownum = 25
For rownum = startrownum To endrownum
If Trim(Sheets("ClubsPayment").Range("A" & Trim(Str(rownum)))) = "" Then
freerownum = rownum
rownum = endrownum
End If
Next rownum

Sheets("ClubsPayment").Range("D" & Trim(Str(freerownum))) = Cmd1.Value
Sheets("ClubsPayment").Range("D2") = Box2.Value
Sheets("ClubsPayment").Range("E2") = Box3.Value
Sheets("ClubsPayment").Range("F2") = Box9.Value
Sheets("ClubsPayment").Range("G2") = Box10.Value
Sheets("ClubsPayment").Range("H2") = Box11.Value
Sheets("ClubsPayment").Range("I2") = Box12.Value
Sheets("ClubsPayment").Range("J2") = Box13.Value
Sheets("ClubsPayment").Range("K2") = Cmd3.Value
Sheets("ClubsPayment").Range("L2") = Box14.Value


End Sub
 
D

davesexcel

Lets see if I got this correct, if you are on row 1, you want the
selections to go into the proper columns in row 1

if you are on row 2 you want the selections to go into the proper
columns in row 2

is this correct??
 
G

Guest

Hi

Thats correct -- however when I change the name in the drop down list Cmd1
-- its then that I want it to go from row 2 with the columns filled to row 3
and fill the columns with the new values I have entered. When I change the
name in Cmd1 it clears the boxes ready for the new data to be entered.
 

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

Similar Threads


Top