+ Reply to Thread
Results 1 to 10 of 10

Weird Set Object and Copy Destination behaivour

  1. #1
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Weird Set Object and Copy Destination behaivour

    Hello! I have a large piece of code below, so i highlighted the problem part. I'm curious, why there is nothing happening when i try to use Range.Copy Destination between Set worksheets in different workbooks. Everything is working fine but this red part. The weirdest thing is that it was working perfectly fine without border formatting part, however it stopped working after it, this function works good in the code below red. Also the side question - is there any obvious way to shorten the formatting or just overall code to make it run faster. Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Weird Set Object and Copy Destination behaivour

    You forgot the "." before your ranges.
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and use Thread Tools (up top) to mark your thread as SOLVED once you have your answer. Thanks!-Lee

  3. #3
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Re: Weird Set Object and Copy Destination behaivour

    hahaha, jesus, i'm so stupid. sorry!

    though 2nd part of question, how can i shorten the border formatting/the rest of the code if possible?

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Weird Set Object and Copy Destination behaivour

    Hi,

    It looks like you only need a Range().Borderaround statement.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Re: Weird Set Object and Copy Destination behaivour

    Ok, thanks everyone. I have shorten the code and modified it a bit - i added at the end of the code function, which saves the opened file in variable folder (saves if exist, creates otherwise cell value defined foldername). But now my loop code broken, i get invalid procedure call or argument error on sFile = Dir right before the end of the loop. I assume it's somehow connected with wrong sFolder path after it saves the file to a new folder. Anyone could help me please?

    Please Login or Register  to view this content.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Weird Set Object and Copy Destination behaivour

    You can't nest one Dir function inside another like that.

  7. #7
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Re: Weird Set Object and Copy Destination behaivour

    Quote Originally Posted by xlnitwit View Post
    You can't nest one Dir function inside another like that.
    So what would be the way to avoid Dir in creating new folder or in choosing next file?

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Weird Set Object and Copy Destination behaivour

    You might use the Scripting.Filesystemobject and its FolderExists method.

  9. #9
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Re: Weird Set Object and Copy Destination behaivour

    Quote Originally Posted by xlnitwit View Post
    You might use the Scripting.Filesystemobject and its FolderExists method.
    Please Login or Register  to view this content.
    Worked perfect, thanks for advice.

  10. #10
    Registered User
    Join Date
    08-15-2017
    Location
    Moscow, RUssia
    MS-Off Ver
    2016
    Posts
    8

    Re: Weird Set Object and Copy Destination behaivour

    Ok, here I am again guys. Modifying and modifying my code. Now I'm working on Error handling part:

    1) I put
    Please Login or Register  to view this content.
    at the start of my loop
    2) I plan to use:
    Please Login or Register  to view this content.
    to create a list of document names at the end of the macro in custom userform. Here I personally see 2 ways how to do it:
    1) I collect the errors data (each time error -> retrieve document name and store it on separate sheet) and later proceed to create a MsgBox/UserForm with this data via ShiftDown
    2) Other way - I'm not sure it's possible, but to create a MsgBox/UserForm and dynamically update it each time error occurs with document name and show it at the end of whole procedure.

    What are your opinions on what is the best way to implement my changes? Thanks in advance!

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy from static destination & paste to dynamic destination
    By Marbleking in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-31-2015, 09:31 AM
  2. Copy chart from Excel to PPT, but pasting with destination theme and embed object?
    By mastro1978 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2014, 09:23 AM
  3. [SOLVED] Destination copy and paste (values only) for copy loop
    By mr_mango81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2013, 08:59 PM
  4. Copy Value From Destination
    By direct2me in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-08-2011, 12:02 PM
  5. copy destination object error
    By Maglor in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-01-2009, 06:23 AM
  6. Using destination filepaths listed in cell contents opposing to coding destination
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2009, 01:23 PM
  7. [SOLVED] How to use Object.Copy(Destination) method PasteSpecial(xlPasteVal
    By RAP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2005, 01:05 PM

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