Combreal

AddRow.vba

Apr 13th, 2021
641
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub addRow()
  2.     Set stock = Sheets("Stock")
  3.     Set test = Sheets("test")
  4.     Dim tTotalRows As Long
  5.     Dim RowPos As Integer
  6.     Dim ws As Worksheet
  7.    
  8.     tTotalRows = stock.Cells.SpecialCells(xlLastCell).Row + 1
  9.     tTotalRows = stock.Range("A" & tTotalRows).End(xlUp).Row
  10.    
  11.     RowPos = ActiveCell.Row
  12.     ActiveCell.EntireRow.Copy
  13.     Range(ActiveCell, ActiveCell).EntireRow.Insert Shift:=xlDown
  14.     Application.CutCopyMode = False
  15.    
  16.     Application.ScreenUpdating = False
  17.     For Each ws In ActiveWorkbook.Worksheets
  18.         If Not ws.Name = "Stock" Then
  19.             ws.Activate
  20.             Cells(RowPos, 1).EntireRow.Copy
  21.             Cells(RowPos, 1).EntireRow.Insert Shift:=xlDown
  22.             Application.CutCopyMode = False
  23.         End If
  24.     Next ws
  25.     Application.ScreenUpdating = True
  26.    
  27.     Worksheets("Stock").Activate
  28.     Range(Cells(2, 5), Cells(4, 5)).AutoFill Destination:=Range(Cells(2, 5), Cells(tTotalRows, 5)), Type:=xlFillDefault
  29. End Sub
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×