ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a macro always I open an Excel Document (https://www.excelbanter.com/excel-programming/335111-run-macro-always-i-open-excel-document.html)

Rui Álvares

Run a macro always I open an Excel Document
 
Hi,

I need to run a macro always I open an Excel document, for exemple, a file
with extensioo .csv.
I found that if I aditioning to the Add-ins the file with the macro saved
with the extensio .xla I have what I want.
The code is write in the "Sub Workbook_Open()" to run since I open the file.
But there's a problem.

I have the code listed below...

Private Sub Workbook_Open()

Columns("A:M").Select
...
...

End Sub

I only write the first line because the problem starts here.
When the code starts to run, the workboow isn't yet open and happens the
error.
If I stop the macro and run it again, the workbook is openned and all is
right.
How can I solve this problem?

Thanks in adance.

Rui



Jim May

Run a macro always I open an Excel Document
 
try instead:
Range("A:M").Select
HTH


"Rui Álvares" wrote in message
...
Hi,

I need to run a macro always I open an Excel document, for exemple, a file
with extensioo .csv.
I found that if I aditioning to the Add-ins the file with the macro saved
with the extensio .xla I have what I want.
The code is write in the "Sub Workbook_Open()" to run since I open the
file. But there's a problem.

I have the code listed below...

Private Sub Workbook_Open()

Columns("A:M").Select
...
...

End Sub

I only write the first line because the problem starts here.
When the code starts to run, the workboow isn't yet open and happens the
error.
If I stop the macro and run it again, the workbook is openned and all is
right.
How can I solve this problem?

Thanks in adance.

Rui





All times are GMT +1. The time now is 07:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com