I don't think the second code snippet in your original post is mine as I can't get Worksheet_Calculate to work either so I always use Worksheet_Change.
In your example above, you don't need to select things before you copy or paste, although that is how the macro recorder writes it for you (just one of those things you learn the more you use vba).
Your code could be...
- Code: Select all
Range("H4:H36").Copy Destination:=Range("AA4")
If it were me (probably because I'm an anorak!) I'd include a variable to only copy the right amount of cells.
When you use the Worksheet_Change routine you get passed a range called Target, which is the range on the sheet that has been changed.
I would use a variable called lastrow (for example) and give it the value Target.Rows.Count which is how many rows have changed.
- Code: Select all
lastrow = Target.Rows.Count
Now you can use lastrow in your range to only get the cells you want.
- Code: Select all
Range("H4:H" & lastrow).Copy Destination:=Range("AA4")
Sorry if I've gone over the top for such a simple thing, but these are the sort of things I wish someone had told me when I started messing around with vba.
