Hi,
I've written a macro which has been working perfectly for all but one user. The original spreadsheets have been in place for around a year however the Macro is new and the final users spreadsheet is new as well.
Whenever i try and run the below for this user only and on any PC i get a "400" error box pop up half way through. if i walk through the process i get the following message
Run-time error '1004':
Application-defined or Object-defined error
when it reaches this line
I can't make sense of it at all.
I read that it could be from copying and pasting into the new spreadsheet so i retried just typing in everything from scratch, the same error persists but only on this spreadsheet.
Any ideas? i'm pulling my hair out.
full macro
I've written a macro which has been working perfectly for all but one user. The original spreadsheets have been in place for around a year however the Macro is new and the final users spreadsheet is new as well.
Whenever i try and run the below for this user only and on any PC i get a "400" error box pop up half way through. if i walk through the process i get the following message
Run-time error '1004':
Application-defined or Object-defined error
when it reaches this line
Rich (BB code):
Range("A65536").End(xlUp).Offset(1, 0).Select
I can't make sense of it at all.
I read that it could be from copying and pasting into the new spreadsheet so i retried just typing in everything from scratch, the same error persists but only on this spreadsheet.
Any ideas? i'm pulling my hair out.
full macro
Rich (BB code):
Sub Submit()
Application.ScreenUpdating = False
' Checks required fields are filled in
Range("A99").End(xlUp).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
Else
Range("A99").End(xlUp).Offset(0, 1).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 2).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 3).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 4).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 5).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 7).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
Range("A99").End(xlUp).Offset(0, 8).Select
If IsEmpty(ActiveCell.Value) Then
MsgBox ("Please Ensure All Fields Are Complete And Then ReSubmit")
Exit Sub
End If
End If
' Open Data Log
MyDataFile = "J:\Ben Sharpe\Private Clients\Data Log.xls"
Set MyWorkbook = Workbooks.Open(MyDataFile)
' Check to see if file is already open
If MyWorkbook.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Cannot update Log, someone currently using file. Please ask user to exit and try again."
Exit Sub
End If
Workbooks("Up selling Marc.xls").Sheets("Sep").Activate
Range("A99").End(xlUp).Select
ActiveCell.Resize(, 10).Copy
Workbooks("Data Log.xls").Sheets("September").Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveCell.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Range("A65536").End(xlUp).Select
ActiveCell.Offset(0, 10).Select
ActiveCell.FormulaR1C1 = "Upsell"
ActiveWorkbook.Close SaveChanges:=True
Workbooks("Up Selling Marc.xls").Sheets("Sep").Activate
Range("A1").Select
ActiveWorkbook.Save
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hi," & vbNewLine & vbNewLine & _
"Sucessful logging of Upsell Case " & Range("B99").End(xlUp) & vbCr & Range("C99").End(xlUp) & vbCr & Range("C99").End(xlUp).Offset(0, 4) & vbCr & Range("C99").End(xlUp).Offset(0, 6) & vbNewLine & _
vbNewLine & "Thank You"
On Error Resume Next
With OutMail
.To = "bens@email.co.uk"
.BCC = ""
.Subject = "Successful Submission of Upsell VALnet Ref: " & Range("B99").End(xlUp)
.Body = strbody
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
SendKeys "%{s}", True 'send the email without prompts
Application.ScreenUpdating = True
MsgBox "Sucessfully Logged - Thank You"
End Sub