Jul 24 2019 02:41 AM
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 but I want to automate it.
I have created a new macro enabled worksheet setup a autorun macro and copied the code from my old macro below it, the issue I seem to be having is it does not seem to select my main worksheet (once its has opened it) as the active one so errors when the code tries paste copied data from another workbook into it.
I have inserted a snipped of the code below and made the text bold where it is bombing out,
Jul 24 2019 07:13 AM
@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"