Inserting a Batch Changes the Formatting of the Cells Below?

Strider89

New Member
Joined
Dec 28, 2017
Messages
22
Now, I've never been accused of being the smartest guy in the room, so I apologize if this is a simple and easy solution, but here goes.

Currently, we have a template that allows users to operate within a batch of specified sheets, with a pre-generated number of line items that they can add or detract from. Because of how specialized the information is, the new line items have to be pulled from a separate sheet and inserted as a new row. The problem is, at the very bottom of each sheet is a Total row, which is 25.50 units tall. When my users insert a new line or batch, the row height stays absolute to that row, rather than being relative. How can I fix this? New line and new batch codes below.

Code:
Sub InsertBatch()'
' InsertBatch Macro
'
' Keyboard Shortcut: Ctrl+Shift+N


Application.ScreenUpdating = False


    Dim rngToCopy As Range
    Set rngToCopy = ThisWorkbook.Worksheets("The Hidden Works").Range("A8:U19")


    rngToCopy.Copy
    Selection.EntireRow.Range("A1").Insert Shift:=xlDown
    Application.CutCopyMode = False


  
    Sheets("The Hidden Works").Visible = -1
 
    
Application.ScreenUpdating = True


End Sub

Code:
Sub InsertRow()

Application.ScreenUpdating = False


    Sheets("The Hidden Works").Visible = -1
    Sheets("The Hidden Works").Range("A21:U21").Copy
    ActiveCell.Rows("1:1").EntireRow.Insert Shift:=xlDown
    Sheets("The Hidden Works").Visible = 2
    


Application.ScreenUpdating = True


End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How about
Code:
Sub InsertBatch() '
' InsertBatch Macro
'
' Keyboard Shortcut: Ctrl+Shift+N


Application.ScreenUpdating = False
  [COLOR=#0000ff] Dim Lr As Long[/COLOR]
   Dim rngToCopy As Range
   [COLOR=#0000ff]Lr = Range("A" & Rows.Count).End(xlUp).Row[/COLOR]
   Set rngToCopy = ThisWorkbook.Worksheets("The Hidden Works").Range("A8:U19")
   
   rngToCopy.Copy
   Selection.EntireRow.Range("A1").Insert shift:=xlDown
   Application.CutCopyMode = False
  [COLOR=#0000ff] Rows(Lr).AutoFit
   Rows(Lr + 12).RowHeight = 25.5[/COLOR]
   
   
   Sheets("The Hidden Works").Visible = -1
   
   
Application.ScreenUpdating = True


End Sub
And something similar for the other macro
 
Upvote 0
I think we're on the right track with this one, Mr. Fluff. However, the macro now constantly sets row 12 to 25.5, regardless of where I decide to insert the new batch, and always sets the last row to AutoFit. What if, after the copy paste, I get all the rows within a range autofit, and then the bottom row with data to be set to 25.5? Is that possible?
 
Upvote 0
In that case change this line
Code:
 Lr = Range("[COLOR=#ff0000]C[/COLOR]" & Rows.Count).End(xlUp).Row
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top