PDA

View Full Version : Run time error 1004 - Application defined or object defined error.



Binod199
03-26-2009, 07:11 AM
Hi,

I am copying data from sheet1 to sheet3. When i run macro for same operation it works fine, but when i try to execute this code on Button event.it gives error.

Run time error 1004
Application defined or object defined error.

Sheets("Sheet1").Select
Range("M10:M14").Select 'Control halts at this line and give error
Selection.Copy
Sheets("Sheet3").Select
Range("B6").Select
ActiveSheet.Paste

Hope someone will solve this problem.

Thanks

Binod kumar

Kenneth Hobs
03-26-2009, 09:54 AM
You should do:
Sheets("Sheet1").Range("M10:M14").Copy Sheets("Sheet3").Range("B6")
Application.CutCopyMode = False

Binod199
03-29-2009, 09:58 PM
Thanks a lot Kenneth for valuable solution.
Your code works great.

Thanks
Binod Kumar

cursw
10-05-2016, 04:52 PM
Hey,

I keep getting the error "Run time error 1004 - Application defined or object defined error" on the bold line listed below. I've must have been on this line for days now and I'm running out of time for getting it done and I'm not sure what I'm doing wrong. The If-else statement may seem a little weird, but I can fix that easy if I can understand why I'm getting this runtime error and get a little help that would be greatly appreciated. Is there anybody out there that can help.

thanks




FunctionactiveSummaryTable()
DimactAvailableStrings() As Variant
Dim t As Integer ' usedas a loop counter
Dim rngAnchorCell AsRange
Dim actSystemNamedRangeAs String
Dim strSystemConfig AsString
Dim platform688I AsString

CallSheets("Active Summary").Select

Sheets("LongevitySummary").Unprotect

strSystemConfig =Worksheets("Recovery Log").Range("A1").Value
If strSystemConfig ="TI14_APB15_688" Then
strSystemConfig =Sheets("Validation Criteria").Range("Active_String_688")
ElseIf strSystemConfig ="TI14_APB15_688I" Then
platform688I =Worksheets("Validation Criteria Active").Range("C2").Value

ElseIf strSystemConfig ="TI14_APB15_773" Then
strSystemConfig =Sheets("Validation Criteria").Range("Active_String_688I")
Else
strSystemConfig =Sheets("ValidationCriteria").Range("Active_String_VA_III_IV")
End If


actSystemNamedRange =platform688I

actAvailableStrings = Worksheets("Validation CriteriaActive").Range(actSystemNamedRange).Value

IfUBound(actAvailableStrings) <>Range("Active_Header_Strings").Count Then Debug.Assert False
End If

Set rngAnchorCell = Sheets("ActiveSummary").Range("B4")
For t = UBound(actAvailableStrings) To 1Step -1
If actAvailableStrings(t, 1) ="" Then
rngAnchorCell.Offset(0,t).EntireRow.Delete
End If
Next t

rngAnchorCell.EntireColumn.AutoFit

Sheets("Active Summary").Protect
End Function

Paul_Hossler
10-05-2016, 05:54 PM
1. If you use the [#] icon at the top, you'll get [ CODE ] and [/ CODE ] tag to paste the code between to format

2. You tagged onto a VERY old thread - It'd be much better to start your own

3. If you could attach a small workbook that demonstrates the problem it'll be easier to have someone look and see



Option Explicit
Function activeSummaryTable()
Dim actAvailableStrings() As Variant
Dim t As Integer ' usedas a loop counter
Dim rngAnchorCell As Range
Dim actSystemNamedRange As String
Dim strSystemConfig As String
Dim platform688I As String

Call Sheets("Active Summary").Select

Sheets("LongevitySummary").Unprotect

strSystemConfig = Worksheets("Recovery Log").Range("A1").Value

If strSystemConfig = "TI14_APB15_688" Then
strSystemConfig = Sheets("Validation Criteria").Range("Active_String_688")
ElseIf strSystemConfig = "TI14_APB15_688I" Then
platform688I = Worksheets("Validation Criteria Active").Range("C2").Value
ElseIf strSystemConfig = "TI14_APB15_773" Then
strSystemConfig = Sheets("Validation Criteria").Range("Active_String_688I")
Else
strSystemConfig = Sheets("ValidationCriteria").Range("Active_String_VA_III_IV")
End If


actSystemNamedRange = platform688I

actAvailableStrings = Worksheets("Validation CriteriaActive").Range(actSystemNamedRange).Value ' BOLDed line

If UBound(actAvailableStrings) <> Range("Active_Header_Strings").Count Then
Debug.Assert False
End If

Set rngAnchorCell = Sheets("ActiveSummary").Range("B4")

For t = UBound(actAvailableStrings) To 1 Step -1
If actAvailableStrings(t, 1) = "" Then
rngAnchorCell.Offset(0, t).EntireRow.Delete
End If
Next t

rngAnchorCell.EntireColumn.AutoFit

Sheets("Active Summary").Protect
End Function



4. It compiles, but without the data in the workbook, it's hard to see what is going on

Taking a GUESS, and assuming that all sheets actually exist ...



actAvailableStrings = Worksheets("Validation CriteriaActive").Range(actSystemNamedRange).Value

uses 'actSystemNamedRange'



'actSystemNamedRange' is only set if 'platform688I' is


actSystemNamedRange = platform688I



'platform688I' is only assigned a value if strSystemConfig = "TI14_APB15_688I"


If strSystemConfig = "TI14_APB15_688" Then
strSystemConfig = Sheets("Validation Criteria").Range("Active_String_688")
ElseIf strSystemConfig = "TI14_APB15_688I" Then
platform688I = Worksheets("Validation Criteria Active").Range("C2").Value
ElseIf strSystemConfig = "TI14_APB15_773" Then
strSystemConfig = Sheets("Validation Criteria").Range("Active_String_688I")
Else
strSystemConfig = Sheets("ValidationCriteria").Range("Active_String_VA_III_IV")
End If


so maybe in


strSystemConfig = Worksheets("Recovery Log").Range("A1").Value


Worksheets("Recovery Log").Range("A1").Value is not = "TI14_APB15_688I"