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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

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