+ Reply to Thread
Results 1 to 4 of 4

Self Incrementing Macro

  1. #1
    Registered User
    Join Date
    06-06-2008
    Posts
    2

    Self Incrementing Macro

    Hello all,

    I hate coming to a new forum requesting help without giving out something first, but I'm in a time crunch and I figured I would double the efforts once things die down here. I took c# programming in college, but it's been a while sense I've touched the class's and I remember even less VBA. I have a question on how to preform the following action in a macro;

    My work book has 4 columns;
    Column A - 2 letter id (not needed for macro)
    Column B - Image Key (This number starts at 001 and continues down each row constantly incrementing itself by one.)
    Column C - Contains either the letter 'F' or is blank to denote the attribute of the Image Key in Column B.
    Column D - The blank area the macro will output the information.

    Now for the meat of the Macro, Basically I need the Macro to start off with the following String Format Exhibit Number _ Page Number (ex. 0001_001). The first portion of the number "0001" denotes the exhibit the image key comes from, the second portion "001" denotes the page. . The qualifier in Column C denotes the break between exhibits. As an example, cell c6 contains 'F'. I need the Macro to recognize that the F is there, Not output information into d6, but instead continue the format down to d7.

    The Macro should start out by searching for the first F, and outputting the 0001_001 into the d column one row down. Then check the next row in the C column and see if theres an F, if not it should increment the Second Portion of the the format by 1. Once it discovers an F, stop incrementing the second portion, add one to the end of the first portion and begin checking again.

    To reiterate;
    Starts with a value of 0000_000
    Macro detects an F in C1, Increments the first number by one (internally) and resets the page number > 0001_000
    Macro Scans next cell down in column C, C2 detects a blank cell > outputs 0001_001 into D2
    Macro Scans next cell down in column C, C3 detects a blank cell > outputs 0001_002 into D3
    Macro Scans next cell down in column C, C4 detects an F > Increments the first number by one (internally) and resets the page number > 0002_000
    Macro Scans next cell down in column C, C5 detects a blank cell > outputs 0002_001 into D5

    This would repeat until it comes to a completly blank row.

    As a qualifier, there will never be 2 rows with adjacent F's, theres always a page between the exhibit markers.

    Please help!

    Thank you so much in advance,

    Colin
    Last edited by VBA Noob; 06-06-2008 at 08:05 AM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Cuken

    Welcome to Exceltip forum

    Please take a couple of minutes and read the Forum Rules then edit your thread title by following the instructions in the rules (Rule 1)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Thanks for changing thread title

    Try this macro

    It uses column A to calculate the last row

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-06-2008
    Posts
    2

    My thanks

    Thank you very much Mudraker, it did exactly what I was looking for it to do. Your a life saver!

+ 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. Macro Loop and Paste in next empty row
    By Rayhoop in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-14-2008, 02:36 PM
  2. country finder lookup macro
    By theghost in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2007, 10:41 PM
  3. Make Called Macro End the First Macro
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2007, 11:38 AM
  4. Help with a Macro (MS Word)
    By Push Latency in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2006, 01:37 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