VBA error message

nmckever

New Member
Joined
Apr 15, 2014
Messages
4
I am trying to load my form but I don't believe that my VBA codes are correct. Whenever I try to dump the information to another worksheet in the workbook and I keep getting error 1004 method range of object changed. My cancel button closes the form but my add information does not work. Below are the codes that I am using for the request form.

'Private Sub UserForm_Click()
'
'requestform.Show
'
'End Sub
Option Explicit


Private Sub UserForm_Initialize()


Me.priority.List = Range("PriorityLevel").Value
Me.request.List = Range("TypeofRequest").Value
Me.category.List = Range("Category").Value


End Sub
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet


Set ws = Worksheets("Master CCO CCB Document List")


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




'check for a email
With Me
If Trim(.email.Value) = "" Then
.email.SetFocus
MsgBox "Please enter the email of the request originator"
Exit Sub
End If

'auto populate



'copy the data to the database

ws.Cells(iRow, 1).Value = .email.Value
ws.Cells(iRow, 2).Value = .change.Value
ws.Cells(iRow, 3).Value = .store.Value
ws.Cells(iRow, 4).Value = .priority.Value
ws.Cells(iRow, 5).Value = .request.Value
ws.Cells(iRow, 6).Value = .category.Value
ws.Cells(iRow, 7).Value = .document.Value
ws.Cells(iRow, 8).Value = .lob.Value
ws.Cells(iRow, 9).Value = .audience.Value
ws.Cells(iRow, 10).Value = .current.Value
ws.Cells(iRow, 11).Value = .desired.Value
ws.Cells(iRow, 12).Value = .reason.Value
ws.Cells(iRow, 13).Value = .roll.Value
ws.Cells(iRow, 14).Value = .location.Value
ws.Cells(iRow, 15).Value = .approve.Value
ws.Cells(iRow, 16).Value = .form.Value
ws.Cells(iRow, 17).Value = Format(Now, "mm/dd/yy hh:mm")

'clear the data
.email.Value = ""
.change.Value = ""
.store.Value = ""
.priority.Value = ""
.request.Value = ""
.category.Value = ""
.document.Value = ""
.lob.Value = ""
.audience.Value = ""
.current.Value = ""
.desired.Value = ""
.reason.Value = ""
.roll.Value = ""
.location.Value = ""
.approve.Value = ""
.form.Value = ""
.email.SetFocus
End Sub
If Me.email.Value = "" Then
MsgBox "Please enter the email of the requester.", vbExclamation, "CCO CCB Document Change Request Form"
Me.email.SetFocus
Exit Sub
End If
Private Sub cmcancel_Click()
Unload Me
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

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