Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BJC BJC is offline
external usenet poster
 
Posts: 3
Default "Run Time Error 1004 Application Defined or Object Defined Error."

Hi,

I get the following error when trying to add the code below to a custom
button. I don't seem to get this error if i add to a drawing object though.
Can anyone help? Am i doing something wrong?

Error i receive is

"Run Time Error 1004 Application Defined or Object Defined Error."


Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
Sheets(i).Select
Range("a2").Select
Range("a1:z2000").Select
'Range("a1,a5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Rows("1300:2500").Select
Selection.Delete Shift:=xlUp
Columns("Q:BG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
Sheets(1).Select
Application.DisplayAlerts = True


End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "Run Time Error 1004 Application Defined or Object Defined Error."

You can't use recorder style code in a worksheet module if you are going to
try to work on the activesheet and the activesheet will not be the sheet
containing the code:

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft
.Range("A1").
End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error goto 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Hi,

I get the following error when trying to add the code below to a custom
button. I don't seem to get this error if i add to a drawing object

though.
Can anyone help? Am i doing something wrong?

Error i receive is

"Run Time Error 1004 Application Defined or Object Defined Error."


Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
Sheets(i).Select
Range("a2").Select
Range("a1:z2000").Select
'Range("a1,a5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Rows("1300:2500").Select
Selection.Delete Shift:=xlUp
Columns("Q:BG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
Sheets(1).Select
Application.DisplayAlerts = True


End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
BJC BJC is offline
external usenet poster
 
Posts: 3
Default "Run Time Error 1004 Application Defined or Object Defined Error."

Thanks for prompt Reply.

What would be the best way to handle the situation?

I basically want a driver sheet at the beginning of the document that saves
formula's on all the sheets as values, and deletes unwanted sheet (listed in
code), in addition to the driver sheet. Thus leaving the formatted remaining
code.

I'd like to do this with a button in the driver sheet. Is this in any way
possible?

BJC.

"Tom Ogilvy" wrote in message
...
You can't use recorder style code in a worksheet module if you are going

to
try to work on the activesheet and the activesheet will not be the sheet
containing the code:

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft
.Range("A1").
End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error goto 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Hi,

I get the following error when trying to add the code below to a custom
button. I don't seem to get this error if i add to a drawing object

though.
Can anyone help? Am i doing something wrong?

Error i receive is

"Run Time Error 1004 Application Defined or Object Defined Error."


Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
Sheets(i).Select
Range("a2").Select
Range("a1:z2000").Select
'Range("a1,a5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Rows("1300:2500").Select
Selection.Delete Shift:=xlUp
Columns("Q:BG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
Sheets(1).Select
Application.DisplayAlerts = True


End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "Run Time Error 1004 Application Defined or Object Defined Error."

I did make a suggestion sohere is the code again. There were a couple of
typos in my original; this is tested and runs OK.

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft

End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error GoTo 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Thanks for prompt Reply.

What would be the best way to handle the situation?

I basically want a driver sheet at the beginning of the document that

saves
formula's on all the sheets as values, and deletes unwanted sheet (listed

in
code), in addition to the driver sheet. Thus leaving the formatted

remaining
code.

I'd like to do this with a button in the driver sheet. Is this in any way
possible?

BJC.

"Tom Ogilvy" wrote in message
...
You can't use recorder style code in a worksheet module if you are going

to
try to work on the activesheet and the activesheet will not be the sheet
containing the code:

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft
.Range("A1").
End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error goto 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Hi,

I get the following error when trying to add the code below to a

custom
button. I don't seem to get this error if i add to a drawing object

though.
Can anyone help? Am i doing something wrong?

Error i receive is

"Run Time Error 1004 Application Defined or Object Defined Error."


Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
Sheets(i).Select
Range("a2").Select
Range("a1:z2000").Select
'Range("a1,a5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues,

Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Rows("1300:2500").Select
Selection.Delete Shift:=xlUp
Columns("Q:BG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
Sheets(1).Select
Application.DisplayAlerts = True


End Sub








  #5   Report Post  
Posted to microsoft.public.excel.programming
BJC BJC is offline
external usenet poster
 
Posts: 3
Default "Run Time Error 1004 Application Defined or Object Defined Error."

cheers
"Tom Ogilvy" wrote in message
...
I did make a suggestion sohere is the code again. There were a couple of
typos in my original; this is tested and runs OK.

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft

End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error GoTo 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Thanks for prompt Reply.

What would be the best way to handle the situation?

I basically want a driver sheet at the beginning of the document that

saves
formula's on all the sheets as values, and deletes unwanted sheet

(listed
in
code), in addition to the driver sheet. Thus leaving the formatted

remaining
code.

I'd like to do this with a button in the driver sheet. Is this in any

way
possible?

BJC.

"Tom Ogilvy" wrote in message
...
You can't use recorder style code in a worksheet module if you are

going
to
try to work on the activesheet and the activesheet will not be the

sheet
containing the code:

Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
With Sheets(i)

.Range("a1:z2000").Copy
.Range("A1:Z2000).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Rows("1300:2500").Delete Shift:=xlUp
.Columns("Q:BG").Delete Shift:=xlToLeft
.Range("A1").
End With
Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
On Error goto 0
Sheets(1).Select
Application.DisplayAlerts = True


End Sub

--
Regards,
Tom Ogilvy

BJC wrote in message
...
Hi,

I get the following error when trying to add the code below to a

custom
button. I don't seem to get this error if i add to a drawing object
though.
Can anyone help? Am i doing something wrong?

Error i receive is

"Run Time Error 1004 Application Defined or Object Defined Error."


Private Sub CommandButton1_Click()
Count = Worksheets.Count
For i = 2 To Count
Sheets(i).Select
Range("a2").Select
Range("a1:z2000").Select
'Range("a1,a5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues,

Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Rows("1300:2500").Select
Selection.Delete Shift:=xlUp
Columns("Q:BG").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Next i

Application.DisplayAlerts = False
On Error Resume Next
Sheets("trialbal").Delete
Sheets("Input").Delete
Sheets(1).Select
Application.DisplayAlerts = True


End Sub












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 '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
I got this problem run-time error 1004 application defined ... Davide Blau Excel Discussion (Misc queries) 2 July 10th 06 09:27 PM
Macro error : Application-defined or object-defined error Joe Excel Discussion (Misc queries) 3 January 27th 06 02:32 PM
1004 App - defined or object-defined error Stan Plumber Excel Programming 2 October 2nd 03 01:52 AM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


All times are GMT +1. The time now is 10:38 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"