ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data Entry Form (https://www.excelbanter.com/excel-programming/346664-data-entry-form.html)

P.Jaimal

Data Entry Form
 
Hi ,
My knowledge about excel programming is very limited. I have a
sheet with months in the first row. The first column contains names of
Products. The intervening grid contains the sales of these items for
these months.

A B C D E
1 APR MAY JUNE JULY
2 PRODUCT 1
3 PRODUCT 2
4 PRODUCT 3
5 PRODUCT 4

My userform has comboboxes "cboMonth" and "cboProduct".A text
box "txtSales".I would like to enter data into the sheet depending
on the selections of the two comboboxes.Example: if
cboMonth.Value="MAY" AND cboProduct.Value ="PRODUCT 3" then the
data from txtSales should get copied to the cell "C4".
I am unable to link these using code.My sheet is very long with many
products(and therefore many Rows).Hence a data entry form is very much
useful .
Please help.

P.Jaimal


Dave Peterson

Data Entry Form
 
Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim myCol As Variant
Dim myRow As Variant

With Worksheets("sheet1") 'whereever this table is.
myCol = Application.Match(cboMonth.Value, .Rows(1), 0)
myRow = Application.Match(cboProduct.Value, .Columns(1), 0)
If IsNumeric(myCol) _
And IsNumeric(myRow) Then
.Range("a1").Cells(myRow, myCol).Value = txtSales.Value
Else
Beep
MsgBox "oopsie"
End If
End With

End Sub

You've posted this to several newsgroups. You may want to post response to
those inquiries that you have an answer or at least an active thread in
..programming.

It'll make less work for others--or may get you improved answers here.


"P.Jaimal" wrote:

Hi ,
My knowledge about excel programming is very limited. I have a
sheet with months in the first row. The first column contains names of
Products. The intervening grid contains the sales of these items for
these months.

A B C D E
1 APR MAY JUNE JULY
2 PRODUCT 1
3 PRODUCT 2
4 PRODUCT 3
5 PRODUCT 4

My userform has comboboxes "cboMonth" and "cboProduct".A text
box "txtSales".I would like to enter data into the sheet depending
on the selections of the two comboboxes.Example: if
cboMonth.Value="MAY" AND cboProduct.Value ="PRODUCT 3" then the
data from txtSales should get copied to the cell "C4".
I am unable to link these using code.My sheet is very long with many
products(and therefore many Rows).Hence a data entry form is very much
useful .
Please help.

P.Jaimal


--

Dave Peterson

P.Jaimal

Data Entry Form
 
Thanks a lot Dave.The code works very well.I am sorry for the multiple
posts.I think that there was a problem somewhere the day I was posting
the message.I was not getting the confirmation that my message was
accepted.Hence the multiple posts.Thanks once again.

P.Jaimal



All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com