Appending cboBox values into cells

C

CMcK

Hi,

I'm working on a a usrFrm which appends cboBox values into cells when the
'Submit' button is clicked.
I want to be able to change the project name (cboBox value) and append fresh
data (values of txtBox & cboBox) in the next row down when the 'Submit'
button is pressed again, and so on (upto 50 times).

Any help would be very much appreciated.

I have written the below code to append the first line of data:

Private Sub cmdSubmit_Click()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ThisWorkbook
Set ws = wb.Sheets("Timesheet")

ws.Activate

ws.Cells(9, 2).Value = Me.cboProjectName.Text
ws.Cells(9, 3).Value = Me.txtProjectNumber.Text
ws.Cells(9, 4).Value = Me.cboProjectPhase.Text
ws.Cells(9, 7).Value = Me.cboMon.Text
ws.Cells(9, 8).Value = Me.cboTues.Text
ws.Cells(9, 9).Value = Me.cboWed.Text
ws.Cells(9, 10).Value = Me.cboThurs.Text
ws.Cells(9, 11).Value = Me.cboFri.Text
ws.Cells(9, 5).Value = Me.cboSat.Text
ws.Cells(9, 6).Value = Me.cboSun.Text

End Sub
 
D

Dave Peterson

Untested...

Private Sub cmdSubmit_Click()

Dim wb As Workbook
Dim ws As Worksheet
Dim NextRow as long

Set wb = ThisWorkbook
Set ws = wb.Sheets("Timesheet")

if me.cboprojectname.text = "" then
msgbox "Please complete the project name!"
exit sub
end if

'no need to activate
'ws.Activate

with ws
nextrow = .cells(.rows.count,2).end(xlup).row + 1

.Cells(nextrow, 2).Value = Me.cboProjectName.Text
.Cells(nextrow, 3).Value = Me.txtProjectNumber.Text
.Cells(nextrow, 4).Value = Me.cboProjectPhase.Text
.Cells(nextrow, 7).Value = Me.cboMon.Text
.Cells(nextrow, 8).Value = Me.cboTues.Text
.Cells(nextrow, 9).Value = Me.cboWed.Text
.Cells(nextrow, 10).Value = Me.cboThurs.Text
.Cells(nextrow, 11).Value = Me.cboFri.Text
.Cells(nextrow, 5).Value = Me.cboSat.Text
.Cells(nextrow, 6).Value = Me.cboSun.Text
end with

End Sub

I used column B to find the next available row. So the project name has to be
filled in.
 
C

CMcK

Dave,
First up, thanks for your reply.
I have run it and unfortunately it's not working. It would appear that each
time the @submit' buttonis prssed, it over-writes existing data instead of
populating the next row down. Any idea why?
Thanks.
CMcK
 
C

CMcK

Dave,

I've figured out why it doesn't work - it was a typo on my part.
Really do appreciate your help. THANK YOU!!!

CMcK
 

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