Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default VBA Run-time error "13"

I am receiving a run-time error "13" when I try to run a USerform in VBA.
When I try to debug the problem - I do not get an indication where the
problem is. Below is the code. Does anyone see what might be causing the
error?

Private Sub cmdadd_click()
Dim lRow As Long
Dim lDate As Long
Dim ws As Worksheet
Set ws = Worksheets("Scrip Purchases")

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

lDate = Me.txtDate.Value

'check for a family name
If Trim(Me.cbofamily.Value) = "" Then
Me.cbofamily.SetFocus
MsgBox "Please enter family name"
Exit Sub
End If

'copy the data to the database
With ws
..Cells(lRow, 1).Value = Me.txtDate.Value
..Cells(lRow, 2).Value = Me.cbofamily.Value
..Cells(lRow, 3).Value = Me.cbovendor.Value
..Cells(lRow, 4).Value = Me.txtdenomination.Value
..Cells(lRow, 5).Value = Me.txtquantity.Value
End With

'clear the data
Me.txtDate.Value = Format(Date, "medium date")
Me.cbofamily.Value = ""
Me.cbovendor.Value = ""
Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
Me.txtDate.SetFocus

End Sub

Private Sub cmdclose_Click()
Unload Me

End Sub

Private Sub UserForm_Initialize()
Dim cfamily As Range
Dim cvendor As Range
Dim ws As Worksheet
Set ws = Worksheets("Lookuplists")

For Each cfamily In ws.Range("familylists")
With Me.cbofamily
..AddItem cfamily.Value
..List(.List - 1, 1) = cfamily.Offset(0, 1).Value
End With
Next cfamily

For Each cvendor In ws.Range("vendorlists")
With Me.cbovendor
..AddItem cvendor.Value
..List(.List - 1, 1) = cvendor.Offset(0, 1).Value
End With
Next cvendor

Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default VBA Run-time error "13"

Sorry - just noticed I posted this in the wrong group. I will re-post in the
Programming group.

"JWNJ" wrote:

I am receiving a run-time error "13" when I try to run a USerform in VBA.
When I try to debug the problem - I do not get an indication where the
problem is. Below is the code. Does anyone see what might be causing the
error?

Private Sub cmdadd_click()
Dim lRow As Long
Dim lDate As Long
Dim ws As Worksheet
Set ws = Worksheets("Scrip Purchases")

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

lDate = Me.txtDate.Value

'check for a family name
If Trim(Me.cbofamily.Value) = "" Then
Me.cbofamily.SetFocus
MsgBox "Please enter family name"
Exit Sub
End If

'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.txtDate.Value
.Cells(lRow, 2).Value = Me.cbofamily.Value
.Cells(lRow, 3).Value = Me.cbovendor.Value
.Cells(lRow, 4).Value = Me.txtdenomination.Value
.Cells(lRow, 5).Value = Me.txtquantity.Value
End With

'clear the data
Me.txtDate.Value = Format(Date, "medium date")
Me.cbofamily.Value = ""
Me.cbovendor.Value = ""
Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
Me.txtDate.SetFocus

End Sub

Private Sub cmdclose_Click()
Unload Me

End Sub

Private Sub UserForm_Initialize()
Dim cfamily As Range
Dim cvendor As Range
Dim ws As Worksheet
Set ws = Worksheets("Lookuplists")

For Each cfamily In ws.Range("familylists")
With Me.cbofamily
.AddItem cfamily.Value
.List(.List - 1, 1) = cfamily.Offset(0, 1).Value
End With
Next cfamily

For Each cvendor In ws.Range("vendorlists")
With Me.cbovendor
.AddItem cvendor.Value
.List(.List - 1, 1) = cvendor.Offset(0, 1).Value
End With
Next cvendor

Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default VBA Run-time error "13"

Very nicely done!

JWNJ wrote:

Sorry - just noticed I posted this in the wrong group. I will re-post in the
Programming group.

"JWNJ" wrote:

I am receiving a run-time error "13" when I try to run a USerform in VBA.
When I try to debug the problem - I do not get an indication where the
problem is. Below is the code. Does anyone see what might be causing the
error?

Private Sub cmdadd_click()
Dim lRow As Long
Dim lDate As Long
Dim ws As Worksheet
Set ws = Worksheets("Scrip Purchases")

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

lDate = Me.txtDate.Value

'check for a family name
If Trim(Me.cbofamily.Value) = "" Then
Me.cbofamily.SetFocus
MsgBox "Please enter family name"
Exit Sub
End If

'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.txtDate.Value
.Cells(lRow, 2).Value = Me.cbofamily.Value
.Cells(lRow, 3).Value = Me.cbovendor.Value
.Cells(lRow, 4).Value = Me.txtdenomination.Value
.Cells(lRow, 5).Value = Me.txtquantity.Value
End With

'clear the data
Me.txtDate.Value = Format(Date, "medium date")
Me.cbofamily.Value = ""
Me.cbovendor.Value = ""
Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
Me.txtDate.SetFocus

End Sub

Private Sub cmdclose_Click()
Unload Me

End Sub

Private Sub UserForm_Initialize()
Dim cfamily As Range
Dim cvendor As Range
Dim ws As Worksheet
Set ws = Worksheets("Lookuplists")

For Each cfamily In ws.Range("familylists")
With Me.cbofamily
.AddItem cfamily.Value
.List(.List - 1, 1) = cfamily.Offset(0, 1).Value
End With
Next cfamily

For Each cvendor In ws.Range("vendorlists")
With Me.cbovendor
.AddItem cvendor.Value
.List(.List - 1, 1) = cvendor.Offset(0, 1).Value
End With
Next cvendor

Me.txtdenomination.Value = ""
Me.txtquantity.Value = ""
End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
cannot use "Create List" and "Share Workbook" same time Devendra Excel Discussion (Misc queries) 0 October 26th 06 06:05 AM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Urgent - Run-Time Error "450" Jeff Excel Discussion (Misc queries) 2 April 24th 06 08:14 PM


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"