CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Cannot copy from excel file

    Hi i have a worksheet in excel with several tabs.In one of them i start a form that will copy a value from one of the cells.According to this value i have to automatically select some cells from another tab and manipulate them.The problem is that before adding the form,everithing worked just fine,but now after adding the form,the needed cells are selected but not copied anymore .I attached the code so that you will see what i mean:


    UserForm1.Show 'show form
    .................
    ................
    ActiveSheet.Cells(2, "GX").Select
    GX22 = ActiveCell.Value
    GXvar = "GX" & count
    ICvar = "IC" & count
    Range(GXvar, ICvar).Select 'select one row to be copied
    Selection.Copy

    i = 4 + GX22 'jost some variable to determine where to paste
    ActiveSheet.Cells(i, "GX").Select 'select cell where copied code will be inserted
    ActiveSheet.Paste


    The thing is that the selection is made but "Selection.copy" is not working and when i try to paste,it will just paste what was in the clipboard.

    Can somebody help?

    thanks

  2. #2
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: Cannot copy from excel file

    Have you tried recording a macro of the events by doing ti manually in Excel. Usually when you look at the recorded macro you can see what it is that you are doing wrong.
    If you find my answers helpful, dont forget to rate me

  3. #3
    Join Date
    Feb 2009
    Posts
    2

    Re: Cannot copy from excel file

    hi
    yes,i tried with that and it records the same things
    "selection.copy" and afterwards "ActiveSheet.Paste" but the thing is that it does not copy my selection and when trying to paste ,it will paste the last thing i copied in the clipboard.It has something to do with that form that i call.

    does anyone have a clue?

  4. #4
    Join Date
    Feb 2002
    Location
    Makati City, Philippines
    Posts
    1,054

    Re: Cannot copy from excel file

    I suspect you have something in your worksheet event (example"Private Sub Worksheet_Change(ByVal Target As Range))" that cancels your copy mode.

    Do you have active events inside the worksheet object?
    Marketing our skills - please participate in the survey and share your insights
    -

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured