Consulting

Results 1 to 8 of 8

Thread: Not really sure how to title this...

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Posts
    22
    Location

    Not really sure how to title this...

    Hi,

    So to start with, some background.

    my macro opens up 6 different workbooks and moves the contents over onto one main sheet. pretty simple...

    the code that moves the contents over is:

    [VBA]ThisWorkbook.Worksheets("DC Master Sheets").Range("A" & mainend, "O" & endrow + 1).Formula = wb.Worksheets(1).Range("A2", "O" & endrow + 1).Formula[/VBA]

    note that the variables mainend and endrow are correct.

    so i have been testing it and it all works fine then i hit one workbook and i got the error

    "Application-defined or object-defined error"



    Debugging!!

    So i tried just moving the first row... worked fine
    [VBA]ThisWorkbook.Worksheets("DC Master Sheets").Range("A3", "O3").Formula = wb.Worksheets(1).Range("A2", "O2").Formula[/VBA]


    Tried first 100 rows... Fine
    [VBA]ThisWorkbook.Worksheets("DC Master Sheets").Range("A3", "O100").Formula = wb.Worksheets(1).Range("A2", "O100").Formula[/VBA]

    First 200... Fine

    First 300... Error!

    So I worked back and narrowed it down further and got to the single cell that was causing the error. (N250 for those that care). I looked at the cell and it had 1095 characters in it.

    so my question is, why can i not move cell contents that have lots of characters in them?

    also how do i fix this. I'm looking for more of a fix than a workaround as i already have several workarounds i could use.


    Edit: range().value will not work either.

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    attach please a sample file

  3. #3
    VBAX Regular
    Joined
    Oct 2012
    Posts
    22
    Location
    I can't really attach a sample file as it contains very sensitive information on hundreds of large UK companies. the explanation above describes in detail the problem, attaching a file will not really help that much anyway.

  4. #4
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    sample file is not current file, but file with dummy data for testing.
    You are asking for help, but you don't want help me

  5. #5
    VBAX Regular
    Joined
    Oct 2012
    Posts
    22
    Location
    Ok i have attached a file, the problem is, i have had to remove lots of information from the sample file. as such the sample file will now work as it is missing the cell (N250) which was causing the error.
    Attached Files Attached Files

  6. #6
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    No code found in your attached file

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [VBA]wb.Worksheets(1).Range("A2", "O100").Copy Destination:=ThisWorkbook.Worksheets("DC Master Sheets").Range("A3", "O100")[/VBA]
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  8. #8
    VBAX Regular
    Joined
    Oct 2012
    Posts
    22
    Location
    you know what i just assumed that wouldn't work. i was overlooking the obvious again.

    tried it and it does seem to work! ill do some more testing and confirm...

Posting Permissions

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