+ Reply to Thread
Results 1 to 5 of 5

Copying loop

  1. #1
    Registered User
    Join Date
    04-22-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Wink Copying loop

    Hi everyone,

    Im looking for a VBA code to copy data from A1 (worksheet 1) into $B$8 (worksheet 2) and then do a printout of "worksheet 2". Then reapeat the same for A2...A3...A4, all the way down to A100. I would also like that macro not to do printout if A is blank.

    Thanks for your help.

  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Copying loop

    hi,

    Welcome to the Forum

    Here is an untested example (without error handling). If you are familar with macros this should point you in the right direction. If you are unfamilar with macros, let us know & someone can provide more details.

    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  3. #3
    Registered User
    Join Date
    04-22-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copying loop

    Thanks for quick answer. I'm not really that much familar with macros. I'll test it today when i put my hands on the spreadsheet @ work I'm just concerned with that line:

    .Range("$B$8").Value2 = RngArr(i, 1)

    Is it not going from A1 to B1...C1 etc. instead of A1...A2...A3?
    Mind me if I'm wrong, as i said im not really familar with VBA, its just my logical thinking

  4. #4
    Registered User
    Join Date
    04-22-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Copying loop

    It's working perfectly. THX a LOT!

  5. #5
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Copying loop

    hi,
    Thanks for the feedback
    Can you please mark the thread as solved?

    Quote Originally Posted by degreez View Post
    ...I'm just concerned with that line:
    Please Login or Register  to view this content.
    Is it not going from A1 to B1...C1 etc. instead of A1...A2...A3?
    Mind me if I'm wrong, as i said im not really familar with VBA, its just my logical thinking
    Hey, it's good to be a logical thinker & to ask questions. If you enjoy Excel & want to learn, read a few of the threads & soak up the tips & tricks and you'll be familar with VBA in no time!

    I should have commented my code more thoroughly to try and explain what was going on.
    To make the macro more efficient I pulled the entire range into VBA as an array* and then iterated through the array (ie the ... "= RngArr(i,1)"), rather than getting info from the sheet cell by cell.

    * I may have my terminology slightly wrong & someone with more knowledge may say that the code could be even more efficient using a different type (non-variant typed) array, but I've had some problems in the past so I stuck with what I know.
    Anyway... on second thoughts, the Excel VBE Help files (search for "array function" & " using arrays") & the below will be more helpful than my rambling!

    Quote Originally Posted by broro183 View Post
    ...Here are some general links/examples:
    http://www.excelforum.com/excel-prog...ml#post2289689
    http://www.excelforum.com/2289718-post139.html & Shg's example later in the thread: http://www.excelforum.com/excel-prog...ml#post2289718
    - In fact, there are good comments right throughout the thread.
    hth
    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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