+ Reply to Thread
Results 1 to 5 of 5

Format Excel Worksheet With VBA

  1. #1
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Format Excel Worksheet With VBA

    I have a workbook, and in column A it has a persons name (first and last), I need to insert a column before A, and in this column I want to add an sfID. Then for each name in column A that does not match the row above it, we increment the ID.



    What I need is

    1) Sort worksheet Column A ASC

    2) Add new Column (so Column A shifts to Column B)

    3) Iterate Column B and compare name to next row

    4) If names are same, key remains same, if different key increments



    Example

    sfID | Name

    sf_1 | Jason Smith

    sf_2 | Nolan Jones

    sf_2 | Nolan Jones

    sf_2 | Nolan Jones

    sf_3 | Mitch McConnel

    sf_4 | Jose Sandoval

    sf_4 | Jose Sandoval



    and we iterate over the entire sheet until no more rows in column B. What would be a VBA macro to accomplish this?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: Format Excel Worksheet With VBA

    One way:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Re: Format Excel Worksheet With VBA

    TMS - thanks as always!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: Format Excel Worksheet With VBA

    Oops, missed the sort:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: Format Excel Worksheet With VBA

    You're welcome.

+ 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. Import excel 2010 format worksheet into database
    By dubbdan in forum Access Tables & Databases
    Replies: 1
    Last Post: 08-21-2013, 06:04 PM
  2. Date Format in userform textbox is different from excel worksheet?
    By z-eighty2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 06:46 AM
  3. combining multiple different excel files with the same format in to 1 worksheet
    By rotterdam010 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 08:31 AM
  4. Excel Macro Worksheet saved in wrong format
    By David_Marsh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2011, 02:20 AM
  5. Excel 2003 Worksheet to Calendar format
    By Wan Fariz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2011, 10:46 PM
  6. Change format of all comments in an Excel worksheet
    By Eric Armstrong in forum Excel General
    Replies: 1
    Last Post: 02-23-2006, 08:35 PM
  7. [SOLVED] Excel 2000 worksheet where I want to convert date format
    By Russell-stanely in forum Excel General
    Replies: 5
    Last Post: 12-18-2005, 10:10 PM
  8. How do I format the tabs of a worksheet in Excel?
    By s_e_morin in forum Excel General
    Replies: 1
    Last Post: 06-27-2005, 05:05 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