User Form Problem

DrummerGnR

New Member
Joined
Feb 13, 2012
Messages
2
Hi, Im Scott and im working on my A2 level ICT coursework, making an excel document.

Ive created a User Form to enter data and everything has worked well except the code means the data is entered in the next column with nothing in.

However i need the data to be entered in e.g. B6-B60 but data is already entered in rows such as R6-R60. This means the data skips these and enters at the last column.

Very hard to explain but would be much appreciated if you could help
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi, thanks for answering! im new to this and new to coding as well... This is the one i have at the moment

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")

'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

'check for a surname number
If Trim(Me.txtSurname.Value) = "" Then
Me.txtSurname.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtSurname.Value
ws.Cells(iRow, 2).Value = Me.txtName.Value
ws.Cells(iRow, 3).Value = Me.txtAge.Value
ws.Cells(iRow, 4).Value = Me.txtGender.Value
ws.Cells(iRow, 5).Value = Me.txtEthnicity.Value
ws.Cells(iRow, 4).Value = Me.txtRegGroup.Value

'clear the data
Me.txtSurname.Value = ""
Me.txtName.Value = ""
Me.txtAge.Value = ""
Me.txtGender.Value = ""
Me.txtEthnicity.Value = ""
Me.txtRegGroup.Value = ""
Me.txtSurname.SetFocus

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,280
Members
449,149
Latest member
mwdbActuary

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
Back
Top