+ Reply to Thread
Results 1 to 4 of 4

Macro to remove row and reset formulas

  1. #1
    Registered User
    Join Date
    01-23-2013
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2007
    Posts
    12

    Macro to remove row and reset formulas

    Not sure if the title is the best description but if you're reading I appreciate the help!

    I have this formula in my excel worksheet to auto number a cell only if anything exists in the cell two spaces over to the left.
    =IF(A4<>"",COUNTA($A$4:A4)&".","")
    In short, I don't need the numbering to start until row 4 and this formula looks to A4 if anything is entered. If something is there, then it begins counting. Works like a champ! The only problem is that if a row is added, the formula is not automatically input to the new row and the rest of the numbering is off. So this macro was created:
    Please Login or Register  to view this content.
    Also works like a champ! So here's the new problem... I need the inverse of the macro now. In short, I need to be able to remove a row and have all the other rows with the formula automatically update and make the necessary corrections to the numbering. Am I asking too much of excel or is it possible to do this with another macro? Or is there an easier way to get the desired results then what I am doing? I also cannot take the credit for the formula and macro above, this forum is fantastic and I borrowed answers from other threads. So I'm very much a novice so please act like you're talking to a child with your response. You won't offend me and I'd greatly appreciate it!
    Last edited by JBeaucaire; 01-25-2013 at 08:47 PM. Reason: Added code tags, as per forum rules. Don't forget!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to remove row and reset formulas

    how about this formula instead:

    =IF(A4<>"",ROW()-3&".","")
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-23-2013
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Macro to remove row and reset formulas

    JB, thanks for the reply, however there is still one factor that is being left out that I might not have mentioned previously. Your formula worked great, however the problem with relying on counting the rows is that there are breaks in the data being reported based on the deparment. So I'll have 1-25, break, then it'll resume at 27-so on. That's why I had that formula for counting only if data was detected in an adjoining cell. Knowing me, there's probably an easier way to do this as opposed to what's circling in my head. I did a down and dirty copy and paste below of a section of the sheet. Had to change the words due to the confidential nature. Again, just trying to find a way to get automatic numbering for the ID# column and for that to continue and reset when rows are added or subtracted from the table. Love this forum and really do appreciate the help!

    Category 1 Category 2 ID# Category 4
    BREAK IN DATA FOR LABELING PURPOSES
    Example 1 Data 1 1. Stuff 1
    Example 2 Data 2 2. Stuff 2
    Example 3 Data 3 3. Stuff 3
    Example 4 Data 4 4. Stuff 4
    Example 5 Data 5 5. Stuff 5
    Example 6 Data 6 6. Stuff 6
    ANOTHER BREAK IN DATA FOR LABELING PURPOSES
    Example 7 Data 7 7. Stuff 7
    Example 8 Data 8 8. Stuff 8
    Example 9 Data 9 9. Stuff 9
    Example 10 Data 10 10. Stuff 10
    Last edited by GSI2013; 01-28-2013 at 04:07 PM. Reason: Example looked off

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to remove row and reset formulas

    If you want to post an actual workbook with some before/after examples, I'll take a look. Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

+ 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