+ Reply to Thread
Results 1 to 20 of 20

Insert new row below data already entered

  1. #1
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Insert new row below data already entered

    Hello,

    I have already entered data into an expenses spreadsheet. I have put totals at the bottom. To enable me to keep adding more entries, I would like a button to click on. Which will create a new row below the data but above the totals. Column A is the dates. I have been trying to go from the bottom of that entry and insert a new row however all the macros i am trying do not work.

    Spread sheet: Date To From Reason Mileage Fare




    ------------------------------Total 100 100

    Thank you for your help in advance.

    Chris

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    Thank you for your reply. I have tried this with and without the button and unfortunately it didn't work.

    Kind Regards
    Chris

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    it does work on my sample. Please attach your sample.

  5. #5
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    I have copied and pasted in what you have provided. When i click on the button nothing still happens. I have gone in design mode and this is what i have;

    Option Explicit

    Sub InsertRows()
    Dim LR As Long, i As Long

    Application.ScreenUpdating = False
    LR = Range("A" & Rows.Count).End(xlUp).Row

    For i = LR To 2 Step -1
    If InStr(1, Cells(i, "A"), "Total", 1) > 0 Then Rows(i).Insert Shift:=xlDown
    Next i

    Application.ScreenUpdating = True

    End Sub

    Private Sub CommandButton1_Click()

    End Sub

    Every time i take out;

    Private Sub CommandButton1_Click()

    End Sub

    When I go back in. It reappears.

    Kind Regards
    Chris

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    Please use code tags with your codes.
    Forget about button for a moment. You first need to run the code and see if it works.
    Please do the following.
    While you are at excel, the cursor should be on the actual sheet
    Press Alt+F11 will take you to the module window,
    Or click developer then visual basics will also take to project window, where you should be able to see the module.
    Now, copy the above code and paste it on the module and press F5 to run it. When you press F5 and do not get any error and then go back to excel to see if the code has inserted rows.
    It would be easier if you could attach a sample so that I can also attach the sample with the code and result.

  7. #7
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    I have followed your instructions. I have run the code. It doesn't error however i have gone back to the spreadsheet and no rows have been added. What do you mean by sample? Do you want the spreadsheet?

    Kind Regards
    Chris

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    Yes, so that I can include the code with the solution and I will then send back to this forum as an attachment, so that you can see it for yourself if the code works , or not.
    Remove any confidential information, then go to advance then attachment

  9. #9
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    Sorry here it is.



    Kind Regards
    Chris
    Last edited by chris19; 04-02-2013 at 05:31 PM.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    Thank you for attachment!
    Now, you have more than 4 sheets. The total on some of the sheets appear in column, B , in others in column D. Which sheet do you want to insert a row on? All sheets?

  11. #11
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    I would like it on Activities, Travel and Rehabilitation Equipment sheets.

    Thank You
    Chris

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Assuming it is the sheet activities, this code works. Do not worry, I will send you as an attachment once we have the solution.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    Thank you ever so much this was driving me crazy!

    Chris

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Please find attached. There is a button on sheet activities (Top row E1 area)
    Attached Files Attached Files
    Last edited by AB33; 04-02-2013 at 05:29 PM.

  15. #15
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello,

    Thank you ever so much! Can i use this code on this macro for my other sheets?

    Kind Regards
    Chris

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    A bit tricky one. The attached code works on three specified sheets, but you can use this code with any sheet as long as you adjust the column, i.e. where the word "total "is . For e.g. in this code , the word "total" is assume to be in column B, in other case it may in different column.


    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello AB33,

    Will my spreadsheet be open for any user to see?
    If so would you please delete it.

    Thank You
    Chris

  18. #18
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    I can not delete, but can empty all sheets, so become blank and no data (Done). I can not do the same with your attachment. You are the only one who you could do it, or ask the moderators to remove all your postings.

  19. #19
    Registered User
    Join Date
    04-02-2013
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Insert new row below data already entered

    Hello AB33,

    I am ever so sorry. I just opened the expenses attachment and can see you have deleted all the information on the spreadsheet.

    Once again thank you ever so much!

    Kind Regards
    Chris
    Last edited by chris19; 04-02-2013 at 06:10 PM.

  20. #20
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Insert new row below data already entered

    Chris,
    I can only amend my own code. I had posted my attachment in post#14. I have amended that attachment, although you can see an attachment, when you open it has four sheets with blank.

+ 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