runtime error 1004 method range of object '_global failed

  • Thread starter Thread starter valdesd
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top