Forum Discussion
eposlink
Jul 24, 2019Copper Contributor
Auto Run a macro in Excel
Hi Can anybody help me, I have a macro that I run from my personal macro workbook that opens up about 10 different spreadsheets copies data and pastes it into my macro enabled workbook, works fine...
JKPieterse
Jul 24, 2019Silver Contributor
eposlink There is no need to select things in VBA. This bit:
Sheets("Customer Credit").Select
Range("A2").Select
ActiveSheet.Paste
can be replaced with:
ThisWorkbook.Sheets("Customer Credit").Range("A2").Paste
ThisWorkbook is a predefined variable which means "The workbook which contains the code that currently runs"