Hi tecsbrain
See if this does as required
Public ws As Worksheet
Option Explicit
Sub Insert_Rows()
Dim Rng As Range, cel As Range
Dim LR As Long, vRows As Long
Dim myDate As String
myDate = Application.InputBox(prompt:= _
"What Date (Format MM/DD/YYYY)?", Title:="Date???", _
Default:=Date, Type:=2) 'Default for 1 row, type 1 is number
If myDate = "" Then Exit Sub
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
Set ws = Sheets("Entries")
Application.EnableEvents = False
With ws
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A" & LR).AutoFill Destination:=.Range("A" & LR & ":A" & LR + vRows), Type:=xlFillDefault
.Range("K" & LR).AutoFill Destination:=.Range("K" & LR & ":K" & LR + vRows), Type:=xlFillDefault
.Range("B" & LR + 1).Resize(vRows, 1).Value = myDate
End With
Call ResetFormatting
Application.EnableEvents = True
End Sub
Sub ResetFormatting()
Dim LR As Long
' ----------------------------------------------------------------------------------------
' Written by..: Julius Getz Mørk; Modified by jaslake for tecsbrain 10/26/2014
' Purpose.....: If conditional formatting ranges are broken it might cause a huge increase
' in duplicated formatting rules that in turn will significantly slow down
' the spreadsheet.
' This macro is designed to reset all formatting rules to default.
' ----------------------------------------------------------------------------------------
Set ws = Sheets("Entries")
With ws
LR = .Range("A" & .Rows.Count).End(xlUp).Row
On Error GoTo ErrHandler
' Disable Events
Application.EnableEvents = False
' Delete all conditional formatting rules in sheet
.Cells.FormatConditions.Delete
' CREATE ALL THE CONDITIONAL FORMATTING RULES:
With .Cells(1, 1).FormatConditions.Add(xlCellValue, xlLess, "=0")
.Interior.Color = RGB(218, 150, 148)
End With
With .Cells(1, 1).FormatConditions.Add(xlCellValue, xlGreater, "=.00277777777778")
.Interior.Color = RGB(141, 180, 226)
End With
' Modify the "Applies To" ranges
.Cells.FormatConditions(1).ModifyAppliesToRange .Range("K2:K" & LR)
.Cells.FormatConditions(2).ModifyAppliesToRange .Range("K2:K" & LR)
End With
ErrHandler:
Application.EnableEvents = True
End Sub
Bookmarks