CleverSnake

attach_forecast vba

Jul 16th, 2020
682
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub copythat()
  2.     Dim first_row As Integer
  3.     Dim last_row As Integer
  4.     Dim main_wb As String
  5.     Dim main_ws As String
  6.    
  7.     Dim final_ws As Worksheet
  8.     main_wb = "свод прогнозов.xlsb"
  9.     main_ws = "прогнозы"
  10.    
  11.     Set final_ws = Windows(main_wb).ActiveSheet
  12.  
  13.     With ActiveSheet
  14.    
  15.         first_row = .Cells(1, 1).End(xlDown).Row
  16.            
  17.         ActiveSheet.Cells(first_row, 1).Select
  18.         Range(Selection, Selection.End(xlDown)).Select
  19.         Range(Selection, Selection.End(xlToRight)).Select
  20.         Selection.Copy
  21.  
  22.     End With
  23.  
  24.    
  25.     With final_ws
  26.         last_row = .UsedRange.Rows(.UsedRange.Rows.Count).Row
  27.         .Cells(last_row, 1).PasteSpecial Paste:=xlPasteValues
  28.         .Cells(last_row, 1).PasteSpecial Paste:=xlPasteFormats
  29.     End With
  30.    
  31. End Sub
RAW Paste Data