+ Reply to Thread
Results 1 to 3 of 3

runtime error 1004 method range of object '_global failed

  1. #1
    valdesd
    Guest

    runtime error 1004 method range of object '_global failed

    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


  2. #2
    Dave Peterson
    Guest

    Re: runtime error 1004 method range of object '_global failed

    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

    valdesd wrote:
    >
    > 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


    --

    Dave Peterson

  3. #3
    valdesd
    Guest

    Re: runtime error 1004 method range of object '_global failed

    thanks Dave
    i'm going to try and i let you Know

    Thanks Again


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1