+ Reply to Thread
Results 1 to 9 of 9

New command button

  1. #1
    Registered User
    Join Date
    05-08-2012
    Location
    Abington, PA
    MS-Off Ver
    Excel 2016
    Posts
    25

    New command button

    Hi,

    I'm looking to see if I can create a command button that prompts me to write a row number that I would like to insert and then copy that information to another sheet. I found the code to enter the row but I can not figure out how to have it add the same row to another sheet with the same information.

    Private Sub CommandButton1_Click()
    Dim rowNum As Integer
    On Error Resume Next
    rowNum = Application.InputBox(Prompt:="Enter Row Number where you want to add a row:", _
    Title:="New Staff", Type:=1)
    Rows(rowNum & ":" & rowNum).Insert Shift:=xlDown
    End Sub

    Thank you for any assistance that you can give...

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: New command button

    Perhaps
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    05-08-2012
    Location
    Abington, PA
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: New command button

    Thank you so much for your reply, the code works it enters the new row... except it does not enter the staff name to the other sheet.
    Last edited by Riverstar5; 08-20-2018 at 03:01 PM.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: New command button

    There is no mention of a staff name in the OP, either the text of your question or in the code.
    Where does one find the staff name, where do you want it to go (which column of the added row)?

  5. #5
    Registered User
    Join Date
    05-08-2012
    Location
    Abington, PA
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: New command button

    I'm so sorry, your right.... "command button that prompts me to write a row number that I would like to insert and then copy that information to another sheet" the other sheet and the row that I want to insert is a new staff name.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: New command button

    Where does the staff name come from?
    Do you want another InputBox so the user can enter it?

    Where does the staff name go? Which cell in the new row (both sheets) does it go into?

  7. #7
    Registered User
    Join Date
    05-08-2012
    Location
    Abington, PA
    MS-Off Ver
    Excel 2016
    Posts
    25

    Re: New command button

    Hi,

    Booth sheets are identical, the command that I posted in the beggining allows me to enter a row and then I type the employee's name in that row... I would like to add the name to the adjasent sheet that is identical to the original one. The sheets are schedules for our clinical staff and when a new staff has to be added to the original sheet I have to add to all the other sheets that are broken down into 6 weeks each sheet. These sheets are about one and half month's of dates and there are 9 sheets all together. I hope this helps...

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: New command button

    So you want a macro that does two things.
    1) Add a new row to two sheets
    2) The next entry in of those newly created rows should be mirrored on the other sheet. After a single entry, that mirroring should stop.
    Is that a description of your need?

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: New command button

    If that describes what you want, try putting this in the ThisWorkbook code module
    Please Login or Register  to view this content.
    And then assiging this
    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 02-02-2016, 10:27 PM
  2. Insert Command Button that will Activate Command Button on a Different Sheet
    By realvirtuality1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2016, 02:11 PM
  3. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  4. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  5. [SOLVED] vba code, command bar, command bar button, one button works but not two
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 09:55 AM
  6. Replies: 1
    Last Post: 09-17-2007, 09:57 PM
  7. [SOLVED] command button:Can i use a command button to open diffrrent sheets
    By Hellboy in forum Excel General
    Replies: 0
    Last Post: 11-03-2005, 11:00 AM

Tags for this Thread

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