Results 1 to 10 of 10

Prompt for # of new rows, copy formulas and conditional formatting

Threaded View

  1. #1
    Registered User
    Join Date
    11-15-2010
    Location
    Arlington, VA
    MS-Off Ver
    Excel 365
    Posts
    34

    Prompt for # of new rows, copy formulas and conditional formatting

    Hi EF,

    Per the subject, I have a workbook where people will continuously enter data at the rate of about 100 rows per day. The first and last columns (A and K) contain formulas and/or conditional formatting.

    I found a macro that purports to do 80% of what I want:

    Sub InsertRowsAndFillFormulas_caller()
      '-- this macro shows on Tools, Macro..., Macros (Alt+F8) dialog 
      Call InsertRowsAndFillFormulas
    End Sub
     
    Sub InsertRowsAndFillFormulas(Optional vRows As Long = 0)
    ' Documented:  http://www.mvps.org/dmcritchie/excel/insrtrow.htm
    ' Re: Insert Rows --   1997/09/24 Mark Hill <[email protected]>
       ' row selection based on active cell -- rev. 2000-09-02 David McRitchie
       Dim x as long 
       ActiveCell.EntireRow.Select  'So you do not have to preselect entire row
       If vRows = 0 Then
        vRows = Application.InputBox(prompt:= _
          "How many rows do you want to add?", Title:="Add Rows", _
          Default:=1, Type:=1) 'Default for 1 row, type 1 is number
        If vRows = False Then Exit Sub
       End If
    
       'if you just want to add cells and not entire rows
       'then delete ".EntireRow" in the following line
    
       'rev. 2001-01-17 Gary L. Brown, programming, Grouped sheets
       Dim sht As Worksheet, shts() As String, i As Long
       ReDim shts(1 To Worksheets.Application.ActiveWorkbook. _
           Windows(1).SelectedSheets.Count)
       i = 0
       For Each sht In _
           Application.ActiveWorkbook.Windows(1).SelectedSheets
        Sheets(sht.Name).Select
        i = i + 1
        shts(i) = sht.Name
    
        x = Sheets(sht.name).UsedRange.Rows.Count 'lastcell fixup
    
        Selection.Resize(rowsize:=2).Rows(2).EntireRow. _
         Resize(rowsize:=vRows).Insert Shift:=xlDown
    
        Selection.AutoFill Selection.Resize( _
         rowsize:=vRows + 1), xlFillDefault
    
        On Error Resume Next    'to handle no constants in range -- John McKee 2000/02/01
        ' to remove the non-formulas -- 1998/03/11 Bill Manville
        Selection.Offset(1).Resize(vRows).EntireRow. _
         SpecialCells(xlConstants).ClearContents
       Next sht
       Worksheets(shts).Select
    End Sub
    But I installed and ran it and it crashes my worksheet ("Not enough system resources to display completely"). This is being done on a pretty high-end computer (16GB RAM, i7 processor) so I doubt it couldn't handle such a task.

    Also, this doesn't handle my conditional formatting requirement.

    I've attached the worksheet in question (it's a binary) if anyone wants to take a stab at it or a different approach.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy Conditional Formatting to other rows
    By zoktolk in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-15-2013, 01:49 PM
  2. Copy Conditional Formatting to other rows
    By Regan_Mitchell in forum Excel General
    Replies: 5
    Last Post: 10-15-2013, 08:19 AM
  3. Replies: 2
    Last Post: 02-07-2012, 05:33 AM
  4. Replies: 2
    Last Post: 06-03-2010, 01:04 AM
  5. Conditional Formatting Copy down Rows
    By SMac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-30-2005, 12:45 PM

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