+ Reply to Thread
Results 1 to 2 of 2

Strange error??

  1. #1
    Bugman
    Guest

    Strange error??

    Hello everybody!!

    I spent a lot of time on a curious bug, and I wanted your advise.
    I created a function that must simlpy copy some cells in another range.
    This function take a range object as parameter to determine source of
    datas to copy:

    Public Function PuF_FormatCpyField(V_Range As Range)

    ' If there is more than 1 project imported, we copy/paste
    ' the formula to all rows containing data
    If GV_NumProjects > 1 Then
    With V_Range.Worksheet
    V_Range.Rows(2).Copy _
    (.Range(.Cells(3, V_Range.Column), .Cells(GV_NumProjects
    + 1, V_Range.Column + V_Range.Columns.Count - 1)))
    End If
    End With
    End Function

    .... but this doesn't work, and a beautiful "Copy Method of Range class
    failed" occurs...

    I've been able to solve this problem by changing
    With V_Range.Worksheet
    by
    With Worksheets("NameOfMyWorksheet")

    I really don't understand why this problem happens... Does somebody
    have an idea?


  2. #2
    Bugman
    Guest

    Re: Strange error??

    I found a better solution:
    With Worksheets(V_Range.Worksheet.Name)
    This one works perfectly great...

    This problem sounds like an Excel bug, don't you think?

    I thought that perhaps my ranges were erroneous, but doing
    V_Range.Rows(2).Activate
    or
    (.Range(.Cells(3, V_Range.Column), .Cells(GV_NumProjects
    + 1, V_Range.Column + V_Range.Columns.Count - 1)).Activate

    works perfectly... Only he copy function doesn't work...

    Strange, isn't it?


+ 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