How do I end a macro

Smilin

Board Regular
Joined
Nov 28, 2019
Messages
67
Platform
  1. Windows
Hello, this is my macro, each day I update my sheet with new values, and the values are pasted below the last line. This is my macro. I am not sure how to end it, end with , end sub, gives me an error both ways. What am I doing wrong ?
VBA Code:
Sub cat2021()
  'define source range
  Dim Lastrow As Long
 
  With Worksheets("Cat2021")
    Lastrow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    Worksheets("hail").Range("A2:A900").Copy
 .Range("A" & Lastrow).PasteSpecial Paste:=xlValues

    Worksheets("hail").Range("N2:N900").Copy
    .Range("B" & Lastrow).PasteSpecial Paste:=xlValues
 
    Worksheets("hail").Range("P2:P900").Copy
    .Range("C" & Lastrow).PasteSpecial Paste:=xlValues
  
 Worksheets("hail").Range("H2:H900").Copy
    .Range("D" & Lastrow).PasteSpecial Paste:=xlValues

 Worksheets("hail").Range("I2:I900").Copy
    .Range("E" & Lastrow).PasteSpecial Paste:=xlValues

 Worksheets("hail").Range("R2:R900").Copy
    .Range("F" & Lastrow).PasteSpecial Paste:=xlValues

 Worksheets("hail").Range("S2:S900").Copy
    .Range("G" & Lastrow).PasteSpecial Paste:=xlValues

 Worksheets("hail").Range("X2:X900").Copy
    .Range("H" & Lastrow).PasteSpecial Paste:=xlValues


End With
 
Last edited by a moderator:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You just need to add End Sub after the End With
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

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