New rows overwriting existing problem

G

Guest

Hello,

I have set up a little workbook that has three sheets in it.

Sheet 1:
is a suedo user form that the user enters data into formatted cells on the
sheet. each cell that a user enters data into is named

Sheet 2: Temp Table
This sheet is a database sheet that has columns that correspond to each cell
on the sheet 1. The data for this table comes from the user entering it into
sheet 1

Sheet 3: Site Reading Log
This sheet is the master log.

The idea is that users would enter values into the 'form' on sheet one.
Sheet 2 stores those values in a single row. Once the user clicks 'Submit'
on SHeet 1, the code is suppsoed to copy the row from sheet 2, into the next
available row in sheet three.

now, this code below does this, but there is a problem. If i try to enter a
new set of data, when i click submit, the code overwrites the data stored in
the previous rows with the new data pasted. What i end up wiht is multiple
rows, containing the same data.

What i actually want is a list of all my data, each in its own row.

Can any one help me with thsi problem?

Code ------
Private Sub CmdSubmit_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("Site Reading Log")

' find first empty row in database

iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

Worksheets("TempTable").Range("DailyReadingEntry").Copy ws.Cells(iRow, 1)

End Sub
 
D

Dave Peterson

See your other thread.

You may want to make sure that all the data in DailyReadingEntry is filled
in--then you don't have to worry about empty cells causing trouble:

with Worksheets("TempTable").Range("DailyReadingEntry")
if .counta(.cells) = .count then
'all the cells are filled in
else
msgbox "Please fill in all the cells!
exit sub
end if
end with

'code to copy would go here.

=================
ps.

Debra Dalgleish has a similar worksheet "form" that does something close to what
you're doing here:
http://www.contextures.com/xlForm02.html

And she has another related procedure here (to print items from the database):
http://www.contextures.com/xlForm03.html
 

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