Specifying Location of Data from Userform

Anitaf

New Member
Joined
Oct 24, 2011
Messages
7
Hi

I'll try and word this correctly....I am creating a user form where all entries (using a command button) are placed in specific cells on the worksheet. So for example if I enter on the 01/10/2011 I spent €10 on clothing, I want the data to be placed in the worksheet adjacent to the row with "1" for the first of oct and under the column heading clothing.

Hope this makes sense
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
Provide more information, and describe exactly what help you require regarding the userform ( do you have any code in there? what have you tried??? )
 

Anitaf

New Member
Joined
Oct 24, 2011
Messages
7
Apologies for not being clear. I am knew to this and experimenting with coding. The code I have is below. Its all down to lack of coding knowledge.

The problem lies where I am copying the data to the database. The way the code is written here, it finds the first empty row and puts the data in here. I have a spreadsheet with specific column headers and I want the data to be placed under the required heading as per the range input on the userform.

To summarize:

Left hand side row are dates in month. Top column has categories such as electricity, fuel, groceries, clothes. The userform has all these categories on a combo box. If the user enters 05.11.2011, selects category electricity and enters amount $121. I want the data to be dropped in a cell adjacent to "5" and under column heading "Electricity".


Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("oct")

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

'check for a part number
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter the spend date"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtDate.Value
ws.Cells(iRow, 2).Value = Me.txtCat.Value
ws.Cells(iRow, 3).Value = Me.txtAmount.Value

'clear the data
Me.txtDate.Value = ""
Me.txtCat.Value = ""
Me.txtAmount.Value = ""
Me.txtDate.SetFocus

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,130,047
Messages
5,639,766
Members
417,109
Latest member
996

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top