runtime error 1004 method range of object '_global failed

V

valdesd

I receive this error when i run this macro from Excel 2000 spanish
version, but no when i run in english version?

Public Function gf_CopyPasteData(s_range As String, s_range2 As String,
i_start_sheet_index As Integer, i_end_sheet_index As Integer) As
Integer
'copies data from sheet one sheet to another sheet
If CInt(Range(s_range).Count) = CInt(Range(s_range2).Count) Then
Sheets(i_start_sheet_index).Select
Range(s_range).Select
Selection.Copy
Sheets(i_end_sheet_index).Select
Range(s_range2).Select
ActiveSheet.Paste
'validation passed, both ranges are of the same size
gf_CopyPasteData = 0
Else
'validation failed, both ranges are a different size
gf_CopyPasteData = 1
End If
End Function

thanks
 
D

Dave Peterson

Where is this code? Is it behind a worksheet module?

If it is, maybe fully qualifying each range would help.

But it really isn't really necessary to select objects to work with them:

Public Function gf_CopyPasteData(s_range As String, s_range2 As String, _
i_start_sheet_index As Integer, i_end_sheet_index As Integer) _
As Integer
'copies data from sheet one sheet to another sheet
If CInt(Range(s_range).Count) = CInt(Range(s_range2).Count) Then
Sheets(i_start_sheet_index).Range(s_range).copy _
destination:=Sheets(i_end_sheet_index).Range(s_range2)
'validation passed, both ranges are of the same size
gf_CopyPasteData = 0
Else
'validation failed, both ranges are a different size
gf_CopyPasteData = 1
End If
End Function
 
Top