userform copy data to more than one location

  • Thread starter Thread starter apndas
  • Start date Start date
A

apndas

I have a userform which currently adds new products to a price lis
which consist of *process,product description,product code,unit o
measure,price per unit* which is located on one workshee
(ProductPriceList), on another worksheet (ProductData) I have 5 column
(a-e) which have headings for 5 different processes, these column
contain unique product descriptions for each of the processes, I us
these for dependant data validation lists, I would really appreciate i
someone can help with code that will add the product description for th
new product to the appropriate process column on workshee
(ProductData). Here is the code I have presently to add the product t
the price list :

Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long
Dim ws As Worksheet
Set ws = Worksheets("ProductPriceList")

'find first empty row in database
lRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row


'check for a process
If Trim(Me.cmbProcess.Value) = "" Then
Me.cmbProcess.SetFocus
MsgBox "Please enter a process"
Exit Sub
End If

'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.cmbProcess.Value
.Cells(lRow, 2).Value = Me.txtDescription.Value
.Cells(lRow, 3).Value = Me.txtCode.Value
.Cells(lRow, 4).Value = Me.txtUnit.Value
.Cells(lRow, 5).Value = Me.txtPrice.Value
End With

'clear the data
Me.cmbProcess.Value = ""
Me.txtDescription.Value = ""
Me.txtCode.Value = ""
Me.txtUnit.Value = ""
Me.txtPrice.Value = ""
Me.cmbProcess.SetFocus


End Su
 
Your code works. I get this error if I don't have a sheet i
ThisWorkbook called "ProductPriceList" - is your spelling OK?

Co
 
Thanks Col

the spelling is correct, and it works fine presently, so i'm not sure
what's happening your end, I'm a newbie to VBA, maybe my workbook
structure is not set up correctly, would it be more helpful if I
attached the workbook
 
Cool - top tip: replace @ with and any dots with spaces so you don't ge
loads of spam in yor email eaddress if you replay to this, or PM me an
I'll do what I can to help...
 
before I attach the file - assuming that my current code is working ok
do you have any suggestions as to the additional task I'm wanting t
perform, would you just add it to the current code???

Regards
Darre
 

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

Back
Top