I've currently got a form w/ a listbox where entries can be selected for export to Excel. However, the code for the command button's OnClick() returns "run-time error '13': type mismatch" and highlights this line:
Here is the complete code:
Any suggestions?
Code:
Row = .Cells(1, 27) + 1
Here is the complete code:
Code:
Private Sub BtnAdd_click()
Dim x As Integer, y As Integer
Dim itm As Variant
Dim xlNew As Excel.Application
Dim sht
Set xlNew = GetObject(, "Excel.Application")
If TypeName(xlNew) = "Nothing" Then
Set xlNew = CreateObject("Excel.Application")
End If
'Row references that cell in the worksheet. The (1, 27) is
'row 1, column 27, which is where I said to put it.
With xlNew.Sheets("Sheet1").Cells
Row = .Cells(1, 27).Value + 1
'Put all your error checking here eg check all the fields
'are entered correctly
'These are just examples, change them to whatever fields you want...
.Cells(Row, 2) = ItemNumber
Data(Row, 1) = Description
End With
If Me!OptionYes = True Then
Data(Row, 8) = "Yes"
Else
Data(Row, 8) = "No"
End If
End Sub
Any suggestions?