+ Reply to Thread
Results 1 to 4 of 4

Macro-Inserting Rows

  1. #1
    Registered User
    Join Date
    07-17-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro-Inserting Rows

    So i have some borrowed code here. Instead if it just inserting a new line/lines based on the active cell (which could be any random spot the user unknowingly may click on), I want the user to know what's going on and be prompted to select where he/sher wants to insert the new line. Perhaps a message box that says "Select where you wish to insert the new line/lines." Thanks for the help in advance!


    Sub InsertRow()

    Dim Rng, n As Long, k As Long
    Application.ScreenUpdating = False
    Rng = InputBox("Enter number of rows required.")
    If Rng = "" Then Exit Sub
    Range(ActiveCell, ActiveCell.Offset(Val(Rng) - 1, 0)).EntireRow.Insert
    k = ActiveCell.Offset(-1, 0).Row
    n = Cells(k, 256).End(xlToLeft).Column
    Range(Cells(k, 1), Cells(k + Val(Rng), n)).FillDown

    End Sub

  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-Inserting Rows

    Maybe like so:
    Please Login or Register  to view this content.
    _________________
    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
    07-17-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro-Inserting Rows

    It's works!!!! You're so AWESOME! Can I also get it to when they hit cancel it doesn't give me a debug error?

  4. #4
    Registered User
    Join Date
    07-17-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro-Inserting Rows

    When it cancels the first message box....i.e the rows to select

+ 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