+ Reply to Thread
Results 1 to 7 of 7

Simple Looping Query

  1. #1
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    812

    Simple Looping Query

    Hi,

    In A1:A1000 I have a list of product names; Product A, Product B etc, each appearing more than once. I would like to create a simple macro that extracts from column A, and puts into a new range starting at C1, each of the names of the products. So C1 would contain the text "Product A", C2 would contain the text "Product B" etc until column C contains the list of product names from A1:A1000.

    I have little doubt that this requires just a few lines of VBA code but even that's beyond me, so can someone please suggest a solution?

    Thanks!
    Last edited by andrewc; 08-31-2013 at 08:19 AM.

  2. #2
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Simple Looping Query

    Perhaps,,

    Select the range.

    Data-> Advance filter--> copy to another location & Unique records only..

  3. #3
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    812

    Re: Simple Looping Query

    Thanks for the quick reply, Elayaz!

    Can anyone please suggest how to accomplish this using VBA?

    Thanks

  4. #4
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Simple Looping Query

    Try this..

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    812

    Re: Simple Looping Query

    Thanks again.

    Can I please ask one silly question:

    When I use this code it does what I required except that it returns two instances in column C of the first product name in column A. Any idea why this would be? I've checked that the two items returned aren't different text.

  6. #6
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Simple Looping Query

    The list should have a header row, otherwise it will treat the first line as a header row, so first entry will repeat.

    Insert a row in the top of column A and give a name to the list ( like "product list")

    Open the code and the change the range to a1:a1001 and run the code.

    It should work perfectly.


    ---------------------------------------------------------------------------
    If my reply helped, Please add reputation (click on the star below the post)
    If the reply solves your problem, Don't forget to mark the thread as "Solved" (Thread Tools->Mark thread as Solved)
    Last edited by elayaz; 08-31-2013 at 06:55 AM.

  7. #7
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    812

    Re: Simple Looping Query

    Perfect, thank you!

+ 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. [SOLVED] Simple Looping Help
    By vexel77 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-10-2013, 03:32 PM
  2. Simple Looping Example needed
    By msmithdynamicsgp in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2011, 09:45 PM
  3. Simple looping statement
    By eonizuka in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2009, 06:59 PM
  4. Simple looping question
    By light in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2005, 10:32 PM
  5. Simple Array Looping
    By Nikky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2005, 06:06 PM

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