+ Reply to Thread
Results 1 to 6 of 6

Do While there are values in column A

  1. #1
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Cape Town
    MS-Off Ver
    Excel 2010
    Posts
    107

    Do While there are values in column A

    Hi,

    I'm a beginner to VBA and I'm having some difficulty. I have values in cells A1:A10. What I wants to do it create a while loop to insert a specific value into B1:B10 ie it will stop when there are nolonger values in A column which will occur at A11.

    Here is my code so far:

    Please Login or Register  to view this content.
    Thanks in advance
    Last edited by concatch; 05-24-2012 at 04:54 AM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Do While there are values in column A

    Hi,

    Try this

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,036

    Re: Do While there are values in column A

    Steffen gave you an answer...
    This is jut modification of your code with Do While loop:

    Please Login or Register  to view this content.
    Edit: as you can see from both answers avoid .Select in your codes.
    Last edited by zbor; 05-24-2012 at 03:18 AM.
    Never use Merged Cells in Excel

  4. #4
    Registered User
    Join Date
    11-08-2006
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    37

    Re: Do While there are values in column A

    Another approach..

    Please Login or Register  to view this content.
    Regards, AB

  5. #5
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Cape Town
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: Do While there are values in column A

    Thank you all for your assistance. Stephen your code continues to populate even if there is a break in the data ie A8 has a value, A9 does not have a value and A10 has a value.

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Do While there are values in column A

    Yes, you didn't specify in your question how the data would be populated, so i made an assumption.

    Then just insert a check on the cell content.

    Please Login or Register  to view this content.
    Or

    If you need the code to continue after the blank cell until the end of column a

    Please Login or Register  to view this content.
    Last edited by Steffen Thomsen; 05-24-2012 at 05:07 AM.

+ 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