+ Reply to Thread
Results 1 to 11 of 11

Copy Destination

  1. #1
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Copy Destination

    Hi all,
    I am really only just getting started with VBA and have finally moved from the Macro recorder in some situations, but still my code is very messy. The code below works fine, but I am having trouble cleaning it up. I want to put in "Copy :=Destination" but I am not sure how to go about it. I was trying to use "Dim" so I could rename the worksheets to make things less confusing, as I can't get my head around how to use "Copy :=Destination" when changing sheets.

    I also am a bit stumped on the changing the font.

    Any help would be appreciated.

    Cheers

    Please Login or Register  to view this content.
    Last edited by JapanDave; 08-11-2011 at 06:27 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Destination

    It's:
    Copy Destination:=

    although there is no need to name the argument.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy Destination

    How do I copy and paste between sheets? No matter what I try I can't get it to work.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Destination

    You are already doing that in your code, which you said was working?

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy Destination

    Forgive my persistence, but even though the code is working there has to be a better way than what I am doing right now? I admit this is not a question on code not working, more so a question purely for my benefit of learning better ways to write code.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Destination

    Well there's no need to select anything to manipulate it, and you could use a couple of worksheet variables to improve the code. Other than that, I'm not really sure what you are looking for - you say you don't know how to copy and paste between sheets, but that's exactly what the code does do.

  7. #7
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy Destination

    As I said before I am still new to VBA, and I understand I copying between worksheets, but I can't write the code to copy between worksheets when using copy destination. In the literature that I am reading right now, it states that you should avoid using ranges and use "Cells" instead.

    And as you said I could improve the code with adding a few variables ect, which is exactly what I am looking for. There is no better way to learn than to have your own code improved upon so you can see what is happening.

    This is the first time I have used "DIM" and is the first loop that I have ever created. I hope you can understand my situation.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Destination

    The only difference using a named argument is that it becomes:
    Please Login or Register  to view this content.
    Cells returns a Range object so whatever you are reading is rubbish if it says that.

    I'll try and put together a revised version later.

  9. #9
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy Destination

    Ahh, now I see where I was going wrong with the copy destination. Thanks. And I really appreciate you taking the time to have a look and see how my code could be cleaned up a bit.

    As for the Cells and Range comment I made, it just stated that it was a better habit to get into to write "Cells" instead of the "Range" when writing code for an object. My explanation was not the best and I apologize.

    Cheers.
    Last edited by JapanDave; 08-10-2011 at 07:25 PM.

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Copy Destination

    Something like this:
    Please Login or Register  to view this content.

  11. #11
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy Destination

    Awsome, that was exactly what I was trying to do. Thanks.


+ 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