+ Reply to Thread
Results 1 to 9 of 9

Loops and errors

  1. #1
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Loops and errors

    Hi, I'm filtering visible cells from one sheet and pasting them into another in a loop.
    Each time I go back to the first sheet I filter the next column and select the new cells, which I then paste into a different section of the second sheet. I do this three times moving across then move down 20 rows and repeat. The problem I'm having is handling the error I get when there are no cells to select. Also I'm missing something as I don't seem to be able to move down the required rows before restarting.

    Here's the code:

    Please Login or Register  to view this content.
    Last edited by KAPearson; 03-20-2014 at 12:01 PM. Reason: correction

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Loops and errors

    Please Login or Register  to view this content.
    Wasn't able to test without a sample file.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Loops and errors

    Thanks Solus. it started off ok but ended up printing all of the columns. I'll have a look and see what went wrong.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Loops and errors

    Printing? Or copying? I didn't see a code to print.

  5. #5
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Loops and errors

    sorry I meant copying. I'll be having another go at it later. Can't see the wood for the trees. Unfortunately the database it reads from is confidential otherwise I'd just upload it, Thanks for your help and I'll post the solution if I work it out.

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Loops and errors

    I really wish I had been able to learn how to do this as a loop but if anyone is interested I have used a an alternative solution

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Loops and errors

    Oops,apologies. Wrong thread lol

  8. #8
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Loops and errors

    Ok I got it copying into the right place and it works fine but even though it ignores the error when there's nothing to copy once it throws up an error the next time.
    Here's the code:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-14-2012
    Location
    England
    MS-Off Ver
    Excel 2010/2013
    Posts
    100

    Re: Loops and errors

    Sorted! It may not be pretty but it works! I'm posting it here in case it helps anyone else.

    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. VBA Loops
    By randomperson15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2010, 12:40 AM
  2. [SOLVED] Excel Throwing Circular Errors When No Errors Exist
    By MDW in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2006, 09:20 AM
  3. [SOLVED] do loops
    By saravanan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2006, 05:55 AM

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