+ Reply to Thread
Results 1 to 6 of 6

Automatically Add/Delete rows based on user input but check current table row count

Hybrid View

clemsoncooz Automatically Add/Delete rows... 12-20-2011, 03:35 PM
clemsoncooz Re: Automatically Add/Delete... 12-21-2011, 10:34 AM
arlu1201 Re: Automatically Add/Delete... 12-21-2011, 11:47 AM
clemsoncooz Re: Automatically Add/Delete... 12-21-2011, 12:50 PM
clemsoncooz Re: Automatically Add/Delete... 12-21-2011, 12:55 PM
arlu1201 Re: Automatically Add/Delete... 12-31-2011, 11:39 AM
  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Automatically Add/Delete rows based on user input but check current table row count

    I am Using Windows 7, Excel 2010.

    My usage of VBA is VERY VERY minimal. I barely know how to navigate.

    This might get confusing so I am going to be as descriptive as possible.

    Overall Goal = I want to add a row within a table (if a row needs to be added), based on a user input.


    I currently have a table of data - Overall 4 rows by 5 columns. (ignoring merged cells, it has 12 rows). (This is for example purposes as any table I might have will be N number of months within each phase).
    ScreenHunter_03 Dec. 20 11.03.jpg

    Column One "Phase" is in Excel Column A and Column Two "% Per..." is in B, Ect.

    The rows titeld Design Phase, Construction Phase, and Post Occupnacy Phase, are merged cells if you can not tell from the picture.

    What I am looking for is a macro that will look at a cell (this cell will be the answer to the question "How many months make up the phase.") and based on that cell, add rows within the table within each phase. So for example, "How many months make up the design phase" in one cell and the answer is (3), then the table has (3) rows within the design phase. If the user inputs (4) - then I would like to see the table ADD a row within Column "Month" and Column "Scheduled Invoice Amount". So the macro needs to look at how many are currently within the table. So if the user inputs (2), then one row will then need to be deleted from the current amount.
    The remaining columns should be left alone (not look any differnt except obviously be taller in height) as those are merged cells.

    This process needs to occur within the other two phases: construction phase and Post Occupancy phase.

    The above pictured table is only an example.
    Any intial starting table might have N number of months within each phase. The resulting table (from the macro) would need to be based upon the user's inputed data.

    Is this do-able?

    Thanks so much for taking the time to read my post and offer any suggestions.

  2. #2
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Automatically Add/Delete rows based on user input but check current table row cou

    Perhaps that I need to monitor the row count of each phase by using something similar to =IF(COUNT(NamedRange)='user input value,"insert rows by macro to match user input", "delete rows by macro to match user input")



    So with that:
    • I would need a macro to insert rows.
    • A macro to delete rows.
    • an event macro to run when an if statment is true / false.


    Thoughts??????

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,168

    Re: Automatically Add/Delete rows based on user input but check current table row cou

    Its good to attach the sample workbook than a jpg so that we can work with your file and provide you a solution.

    I have re-designed your file a bit, so its easier to manage. I have put the months in columns from left to right. In this case, you do not need to insert / delete rows. Let me know if this works for you and then we can assist with any further automation if required.
    Attached Files Attached Files
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Automatically Add/Delete rows based on user input but check current table row cou

    Hey thanks for looking at this and taking your time to construct an answer. Unfortunately, due to the nature of how this file is going to be used and where its going to be used....it needs to stay in the same layout and format as shown in the the picture.

    The "scheduled invoice amount" column is calculated off of how many months are within each phase. We have a set amount to be invoiced in each phase, so depending on how many months are to be invoiced (user inputed value) determines how much to invoice.

    I have attached a sample table:
    SampleWithTable.xlsm

  5. #5
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Re: Automatically Add/Delete rows based on user input but check current table row cou

    Just noticed my formulas in column F are incorrect. Corrected version attached. SampleWithTable_updated.xlsm

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,168

    Re: Automatically Add/Delete rows based on user input but check current table row cou

    What I am looking for is a macro that will look at a cell (this cell will be the answer to the question "How many months make up the phase.") and based on that cell, add rows within the table within each phase
    Which is this cell? Can u give me the cell location or will it be a prompt to the user at each phase?

+ 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