Thread: Excel help!
View Single Post
Old 29-03-2004, 09:41   #14
gazzae
Inactive
 
gazzae's Avatar
 
Join Date: Jun 2003
Location: Belfast
Age: 46
Posts: 4,594
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
gazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronzegazzae is cast in bronze
Re: Excel help!

Instead of all those copys and pastes and changing between forms it would be easier to do it like this.

Code:
With Worksheets("Student_database")
    .Cells(2, 3).Value = Worksheets("Student_form").Cells(2, 2).Value
    .Cells(2, 4).Value = Worksheets("Student_form").Cells(2, 3).Value
End With
Then you could put a loop around it like such

Code:
strmyloopvar = Worksheets("Student_form").Cells(2, 2).Value
strstudentdbrow = 1
strstudentform = 1

do until strmyloopvar = ""
     strmyloopvar = Worksheets("Student_form").Cells(strstudentform, 2).Value
          With Worksheets("Student_database")
              .Cells(strstudentdbrow, 3).Value = Worksheets("Student_form").Cells(strstudentform, 2).Value
              .Cells(strstudentdbrow, 4).Value = Worksheets("Student_form").Cells(strstudentform, 3).Value
          End With

strstudentdbrow = strstudentdbrow + 1
strstudentform = strstudentform + 1

loop

On the Student_form sheet if you want to find a row with no data just do a loop and then loop down until the value of the cell is = "" e.g

Code:
strmyloopvar = Worksheets("Student_database").Cells(2, 2).Value

do until strmyloopvar = ""
     strmyloopvar = Worksheets("Student_database").Cells(strstudentdbrow, 2).Value

strstudentdbrow = strstudentdbrow + 1

loop
Then if you remove the strstudentdbrow = 1 from above the first loop then strstudentdbrow will be equal to the first row where the cell was blank and the first loop above will start putting the values into this cell.

Dunno if this code will work, as its early monday morning and I've just written it off the top of my head, but it should give you an idea of what you need to do.
gazzae is offline   Reply With Quote