+ Reply to Thread
Results 1 to 3 of 3

Clear Contents in an insert rows x number of times Macro

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Question Clear Contents in an insert rows x number of times Macro

    I have a macro that inserts a number of rows (input by the user) at the next available row, I just need this to also clear the contents. I tried inserting Selection.ClearContents into the code but I'm new to this and wasn't sure where to put it. Any help much appreciated:

    Private Sub CommandButton15_Click()
    Dim lngRows As Long, lngNextRow As Long

    On Error GoTo Finish

    lngRows = CLng(InputBox("How many rows do you wish to insert?"))
    lngNextRow = Range("A" & Rows.Count).End(xlUp).Row + 1

    Rows(43).Copy Rows(lngNextRow & ":" & lngNextRow + lngRows - 1)

    Finish:
    If Err.Number <> 0 Then MsgBox Prompt:="Please ensure you only enter numeric values!"

    End Sub






    Thanks in advance

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Clear Contents in an insert rows x number of times Macro

    Hi, Rachael Whyment,

    maybe just paste the formats over?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    04-18-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Clear Contents in an insert rows x number of times Macro

    Fantastic!

    Thank you


+ 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