Really hope you can help me out here. My knowledge of vba is quite poor. I hope I can explain this to you correctly.
I am having a problem using data from my combobox to find the cell on the worksheet and write to a specific adjacent cell.
Worksheet name is Jan
ComboBox1 Name is cmbDate
ComboBox2 Name is cmbCat
TextBox name is txtAmount
CommandButton1
Using the date value from cmbDate, find this text in Row A of worksheet Jan and write the Value of txtAmount in a cell adjacent to the date and under the cell equal the cmbCat value when the CommandButton1 is pressed.
I have uploaded the workbook 'Household Planner' to make it a little clearer
Your file won't open for me, can you try saving the file above in Excel 97-2003 format .xls?
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
I have saved it and uploaded as requested (household planner.1). Thanks for taking the time.
Uploaded now is my previous post![]()
This is how I would do that. you seem to have some variations on the individual sheets and the titles of columns and such. There's no need to worry about that, your form can grab the appropriate titles across row 5 in each sheet, it won't matter if they're the same from sheet to sheet. These macros will get the column categories and the dates from the "activesheet", the enter the values into the table accurately as you make entries.
If you select the same date/category a second time, it will add the values together.
Private Sub cmdAdd_Click() Dim iRow As Long, iCol As Long If cmbDate = "" Then MsgBox "please select a date" cmbDate.SetFocus Exit Sub End If If cmbCat = "" Then MsgBox "please select a category" cmbCat.SetFocus Exit Sub End If If txtAmount = "" Then MsgBox "please enter then amount" txtAmount.SetFocus Exit Sub End If With ActiveSheet iRow = .Range("A:A").Find(cmbDate.Value, LookIn:=xlValues, LookAt:=xlWhole).Row iCol = .Range("5:5").Find(cmbCat.Value, LookIn:=xlValues, LookAt:=xlWhole).Column .Cells(iRow, iCol) = .Cells(iRow, iCol) + txtAmount End With 'clear the data cmbDate.Value = "" cmbCat.Value = "" txtAmount.Value = "" cmbDate.SetFocus End Sub Private Sub cmdDone_Click() Unload Me End Sub Private Sub UserForm_Initialize() Dim cItem As Range Dim ws As Worksheet Set ws = ActiveSheet For Each cItem In ws.Range("5:5").SpecialCells(xlConstants).Offset(, 1) With Me.cmbCat If cItem <> "" And cItem <> "Total" Then .AddItem cItem.Value End With Next cItem For Each cItem In ws.Range("A:A").SpecialCells(xlConstants, xlNumbers) With Me.cmbDate .AddItem cItem.Value End With Next cItem End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Worked a treat, just a bit of tidying up to do as you say. Thank you so much, I really appreciate it and admire your skill.
If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks