I’ve talked about some of the Excel VBA I’ve done before, and here’s a new thing I learned today.
Problem
One part of my application selects a range from one worksheet in the spreadsheet and pastes it onto another. Originally, the code I used looked like this:
destinationWorksheet.Range("A2").Select
ActiveSheet.Paste
There is one problem I was unaware of. Every time the .Paste operation executed, it added a new “Named Range” to the ActiveSheet. I only realized this when snooping around in the Properties for the Excel file, where I found (to much dismay) 840 different “Named Ranges” referring to data long since thrown away! An older version of my application, which used this unspecified Paste operation much more frequently, had even more of these attached to numbers of other worksheets. Continue reading ‘Clean pastes with Excel VBA’

Recent Comments