+ Reply to Thread
Results 1 to 5 of 5

VB - Moving data based on If

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    VB - Moving data based on If

    Hi everyone,

    In cells B1:B1000 I have some alphanumeric data (postcode data). In cells C1:C1000 I have either 'Yes' or 'No' in each cell (there are no blanks). What I wish to automate with VB is to move all cells in the range B1:B1000 that have 'Yes' in their adjacent C column to column H and all those that have 'No' to column J. So essentially i should end up with two lists of data in H and J - data based on 'Yes' and 'No' respectively.

    One final kicker though! (sorry!). Is it possible for the data to be ordered without blanks. I.e if cells B23 and B45 are the first two instances of data that have 'Yes' then then would go into H1 and H2 respectively (rather than H23 and H45).

    Thanks in advance. Great community!
    Last edited by D_N_L; 08-23-2011 at 02:41 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VB - Moving data based on If

    Hi Plumby, can you upload a mock workbook with mock data as well as a before and after regarding the data being moved? If you do that someone here should be able to fulfill your requirements.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: VB - Moving data based on If

    Hi there,

    (Thanks mod).

    I have attached an example workbook of what I mean. You can see that column H contains all the 'Yes' postcodes and column J all the 'No' postcodes. The data in column B and C will differ every time too. For example there may be 7 postcodes (as in the example) or 700 postcodes.

    But each time there will always be a 'Yes' or 'No' in column C next to the postcode. The data will contain no blanks either.

    Thanks in advance.
    Attached Files Attached Files

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VB - Moving data based on If

    Hi Plumby, take a look at the following workbook and let me know if it meets your requirements. All you have to do is click the "Sort Post Codes" button.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: VB - Moving data based on If

    That's brill - thanks very very much!

    Rep added.

+ 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