So the user is using a userform I built to input the data onto the sheet.
Its working as its supposed to except the value in textbox 1 needs to be put in one cell or the other depending on the selection of apples or oranges from the combo-box. Here is the full code, when the userform is submitted the data from the userform is actually getting entered on two sheets. The error Im getting is:
"Runtime Error, Script out of Range", and its highlighting the line:
"set ws worksheets("records"): ws.Activate"
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim we As Worksheet
Dim Count, temp As Integer
For Count = 1 To 3
Next
Set ws = Worksheets("Records"): ws.Activate
'''find first empty row in database
''iRow = ws.Cells(Rows.Count, 1) .End(xlUp).Offset(1, 0).Row
'revised code to avoid problems with Excel tables in newer versions
iRow = Worksheets("Records").Range("A65536").End(xlUp).Row + 1
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.ComboBox2.Value
ws.Cells(iRow, 3).Value = Me.ComboBox3.Value
ws.Cells(iRow, 4).Value = Me.TextBox1.Value
ws.Cells(iRow, 5).Value = Me.DTPicker1.Value
ws.Cells(iRow, 6).Value = Me.DTPicker2.Value
Set we = Worksheets("Chart View"): we.Activate
Range("A1").Value = 1
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1) = Range("A" & Range("A" & Rows.Count).End(xlUp).Row) + 1
iRow = Worksheets("Chart View").Range("A65536").End(xlUp).Row 'Had to delete the "+1" part to get the data to appear on the right row.
we.Cells(iRow, 2).Value = Me.ComboBox2.Value
If Me.ComboBox3.Value = "Apples" Then
we.Cells(iRow, 3).Value = TextBox1.Value
End If
If Me.ComboBox3.Value = "Oranges" Then
we.Cells(iRow, 4).Value = TextBox1.Value
End If
we.Cells(iRow, 5).Value = Me.DTPicker1.Value
we.Cells(iRow, 6).Value = Me.DTPicker2.Value
End Sub

Originally Posted by
Whizbang
What errors are you getting? What is it doing or not doing?
The only issue I got was that it was putting the row number in column A, but the values in the next row down.
This worked fine for me:
Set we = Worksheets("Chart View"): we.Activate
Range("A1").Value = 1
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1) = Range("A" & Range("A" & Rows.Count).End(xlUp).Row) + 1
iRow = Worksheets("Chart View").Range("A65536").End(xlUp).Row 'Had to delete the "+1" part to get the data to appear on the right row.
we.Cells(iRow, 2).Value = Me.ComboBox2.Value
If Me.ComboBox3.Value = "Apples" Then
we.Cells(iRow, 3).Value = TextBox1.Value
End If
If Me.ComboBox3.Value = "Oranges" Then
we.Cells(iRow, 4).Value = TextBox1.Value
End If
Bookmarks