+ Reply to Thread
Results 1 to 4 of 4

Need help with macro copying data

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Merry Olde Englande
    MS-Off Ver
    Excel 2003
    Posts
    2

    Need help with macro copying data

    Hello all

    I'm writing a macro to create and populate a bunch of forms using data from a seperate spreadsheet.

    It's all working as it should except for the line of code that actually populates the cells in the newly created form.

    Here is an example

    Range("A21").Select
    ActiveCell.FormulaR1C1 = Sheets("data").Range("GY" & LIIS_Number)

    Whats vexing me is that this formula works for some of the cells but not others. I've got a Do loop running to create multiple forms and the first form comes out fine, the second gets stuck and the only thing I can see that might be causing the error is that the second form contains a cell with over 170 characters while the first form only holds cells below 140 characters. I'm not even sure if this is an issue.

    So my question. What might cause that piece of code up there to not work at what is supposed to be doing? Could format or the cell contents be the problem? Is there a better way to populate the form (i could try and do the copy/paste method but is there a better way?)?

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need help with macro copying data

    Please attach a sample copy of the file you are using and the code as well.

    To Attach a File:

    1. Click on Go Advanced.
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-21-2012
    Location
    Merry Olde Englande
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Need help with macro copying data

    Unfortunately I can't attach the data that is causing me grief, I work in criminal justice and the data concerns Children and Young People, sharing that is a big no-no.

    As for my code, the vast bulk of it is formatting instructions, although it did occur to me that i am trying to populate a cell that has been merged. Might this be the route of the problem?

    I've actually resolved the issue replacing the code above with a copy and paste instruction. I'd still be very interested to know if there are limitations to that line of code or if there are issues with populating merged cells.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need help with macro copying data

    You can actually upload a sample file with dummy data but ensure that the format and layout is the same as your original file.

    Merged cells do seem to be a pain in the wrong place most of the time. Without seeing your code and the file, its tough to ascertain what could be causing the issue.

+ 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