S
siamadu
I am new to learning how to program with VBA and Excel. This code cam
from the book, “VBA for Excel Made Simple” that I borrowed from th
library. When I run the code, I keep getting the error message: Run-tim
error '13': Type mismatch.
The purpose of this form is to insert an extra row and add th
representative name in the RepName list.
I have also attached the sample excel file and the explanation tha
came from the actual book. Thank you for all your help in advance.
Code
-------------------
Private Sub UserForm_Initialize()
RepBox = ""
SalesBox = "0"
For Each Cell In Range("rep_name")
RepList.AddItem Cell.Value
Next
End Sub
Private Sub AddButton_Click()
RepBox.SetFocus
With RepBox
If .Value = "" Then
MsgBox "Enter a name for the rep to be added"
.SetFocus
End If
If .Value = "" Then
MsgBox "Enter a sales value for the rep given"
SalesBox.SetFocus
End If
End With
With Worksheets("weeklysales").Range("total")
newSumSales = SalesBox.Value + .Offset(0, 1)
.EntireRow.Insert
.Offset(-1, 0) = RepBox.Value
.Offset(-1, 1) = SalesBox.Value
.Offset(0, 1) = newSumSales
Range("sales_to_date", .Offset(-1, 1)).Name = "sales_to_date"
End With
RepList.AddItem RepBox.Value
Unload Me
End Sub
Private Sub CancelButton_Click()
Unload Me
End
End Sub
-------------------
+-------------------------------------------------------------------
|Filename: SALESMAN.xls
|Download: http://www.thecodecage.com/forumz/attachment.php?attachmentid=75
+-------------------------------------------------------------------
from the book, “VBA for Excel Made Simple” that I borrowed from th
library. When I run the code, I keep getting the error message: Run-tim
error '13': Type mismatch.
The purpose of this form is to insert an extra row and add th
representative name in the RepName list.
I have also attached the sample excel file and the explanation tha
came from the actual book. Thank you for all your help in advance.
Code
-------------------
Private Sub UserForm_Initialize()
RepBox = ""
SalesBox = "0"
For Each Cell In Range("rep_name")
RepList.AddItem Cell.Value
Next
End Sub
Private Sub AddButton_Click()
RepBox.SetFocus
With RepBox
If .Value = "" Then
MsgBox "Enter a name for the rep to be added"
.SetFocus
End If
If .Value = "" Then
MsgBox "Enter a sales value for the rep given"
SalesBox.SetFocus
End If
End With
With Worksheets("weeklysales").Range("total")
newSumSales = SalesBox.Value + .Offset(0, 1)
.EntireRow.Insert
.Offset(-1, 0) = RepBox.Value
.Offset(-1, 1) = SalesBox.Value
.Offset(0, 1) = newSumSales
Range("sales_to_date", .Offset(-1, 1)).Name = "sales_to_date"
End With
RepList.AddItem RepBox.Value
Unload Me
End Sub
Private Sub CancelButton_Click()
Unload Me
End
End Sub
-------------------
+-------------------------------------------------------------------
|Filename: SALESMAN.xls
|Download: http://www.thecodecage.com/forumz/attachment.php?attachmentid=75
+-------------------------------------------------------------------