ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   URGENT!!!!!!!!!!!!!!! Problem with macros in Excel (https://www.excelbanter.com/excel-programming/294316-urgent-problem-macros-excel.html)

Anamika[_2_]

URGENT!!!!!!!!!!!!!!! Problem with macros in Excel
 
H

I wrote a macro in excel "sheet1" .What this macro does is to export data from one Excel "sheet2" to "Sheet1". It was working fine in all systems. till 2 days back. But now it works in some and it doesn't work in some systems.

It gives an error saying ""Runtime-Error '9' Subscript Out of Range."

At this line i am actually activating the sheet from whcihc it has to copy. Ie " Windows("Sheet2.xls").Activate

Some one pls hel


Tom Ogilvy

URGENT!!!!!!!!!!!!!!! Problem with macros in Excel
 
is Sheet2 the name of the sheet or the name of the workbook.

anyway, a subscript out of range error says you are providing an argument to
Windows or other collection which is invalid. For you example, there is no
workbook with the name Sheet2.xls

--
Regards,
Tom Ogilvy


"Anamika" wrote in message
...
Hi

I wrote a macro in excel "sheet1" .What this macro does is to export data

from one Excel "sheet2" to "Sheet1". It was working fine in all systems.
till 2 days back. But now it works in some and it doesn't work in some
systems.

It gives an error saying ""Runtime-Error '9' Subscript Out of Range." .

At this line i am actually activating the sheet from whcihc it has to

copy. Ie " Windows("Sheet2.xls").Activate"

Some one pls help




Tom Ogilvy

URGENT!!!!!!!!!!!!!!! Problem with macros in Excel
 
If that were the case, you wouldn't get a subscript out of range error.

Add a new workbook and run this macro from that

Sub ShowAll()
Dim wkbk as Workbook
Dim sh as Worksheet
for each wkbk in Application.Workbooks
sStr = sStr & vbNewLine & "" &wkbk.Name & "<"
for each sh in wkbk.Worksheets
sStr = sStr & vbNewLine & " " & sh.name & "<"
Next
Next
msgbox sStr
End Sub

--
Regards,
Tom Ogilvy

"Anamika" wrote in message
...
Hi

Thx for the reply

Sheet2.xs is name of workbook. And both sheet1 and sheet2 are opened while

i run the macro.



Gerrit van Stempvoort

URGENT!!!!!!!!!!!!!!! Problem with macros in Excel
 
As Tom said,
"anyway, a subscript out of range error says you are providing an argument
to
Windows or other collection which is invalid. For you example, there is no
sheet with the name Sheet2."

I had such a error when I was using a macro written on a UK Excel in a Dutch
Excel.
In the Dutch Excel a sheet is called "blad" and I got a similair error.
So I think that you have a similair problem.

Succes,

Gerrit

"Anamika" schreef in bericht
...
Hi

Thx for the reply

Sheet2.xs is name of workbook. And both sheet1 and sheet2 are opened while

i run the macro.




All times are GMT +1. The time now is 03:00 PM.

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