+ Reply to Thread
Results 1 to 2 of 2

VBA - Insert User determined number of cells with a specific formatt

  1. #1
    Registered User
    Join Date
    05-30-2019
    Location
    London
    MS-Off Ver
    2017
    Posts
    2

    VBA - Insert User determined number of cells with a specific formatt

    Hi there,

    Hoping someone can help.

    I have a code (see below) which enables a user to choose how many cells they would like to insert when running the macro. However, I don't want the inserted cells to adopt the format of the row from which they were inserted below. I want them to have the format of a different row. How can I make this happen? Ideally, before the required number of cells are inserted, Row 'X' (which has the format for which I would like) is copied and this is pasted as formats (and formulas actually) into the newly created cells.

    Does this make sense?

    Below is current code.....

    Sub InsertMultiChildRowsNoFill()

    ' Disable Excel Features whilst macro runs

    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    Application.ScreenUpdating = False

    ' Declaration of row count variable
    Dim iCountRows As Integer

    'Trigger input message to appear - in terms of how many rows to insert
    iCountRows = Application.InputBox(Prompt:="How many rows do you want to inset, starting with row " _
    & ActiveCell.Row & "?", Type:=1)

    ' Error Handling - end the macro if a zero or negative integer input value is entered
    If iCountRows <= 0 Then End

    'Based on number of rows specified, insert these rows
    Rows(ActiveCell.Row & ":" & ActiveCell.Row + iCountRows - 1).Insert Shift:=xDown

    'Re-enable Excel features after macro is un

    Application.Calculation = xlCalculationAutomatic
    Application.EnableEvents = True
    Application.ScreenUpdating = True


    End Sub

  2. #2
    Registered User
    Join Date
    05-30-2019
    Location
    London
    MS-Off Ver
    2017
    Posts
    2

    Re: VBA - Insert User determined number of cells with a specific formatt

    I can attach the document from which I'm working from if necessary

+ 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. user-determined adding of cell values in a column: code breaks down after 2 cells
    By simz92 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2017, 05:12 AM
  2. [SOLVED] Average of specific cells with numbers determined by multiple criteria
    By holycrapitsaduck in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-27-2016, 10:40 AM
  3. Replies: 3
    Last Post: 03-23-2016, 09:56 AM
  4. Need to pick pre-determined Date entry in User Form
    By Colin Smit in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-13-2014, 08:40 AM
  5. [SOLVED] Construct a formula on a pre-determined cell for a pre-determined duration of cells
    By Shaun Gemiver in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-03-2013, 11:14 AM
  6. Fill cells determined by Time Value selection w/user form
    By ShannonHowell in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 09:56 PM
  7. Replies: 3
    Last Post: 02-13-2012, 04:43 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