Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with selecting all cells in a sheet -- Error 1004

Hello,

I am having problems selecting all the cells of a worksheet. I am
getting Error 1004.

I have two workbooks. Workbook1 is where the VBA code is running. I
want to select all the cells of the first sheet of Workbook2. After
opening Workbook2, I make it invisible.

In the vba code I call a subroutine and pass it Workbook2.

The following code causes error 1004:

dim ws as worksheet

set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select ***Error happens here

Any help would be greatly appreciated. I am activating the worksheet
in Workbook2 and then trying to select the cells. Does anyone know
why I am getting the error?

Any help would be greatly appreciated. I am totally stuck here.

Thanks,
Scott
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Help with selecting all cells in a sheet -- Error 1004

I don't think you can select cells in a hidden workbook.
If the workbook is hidden, why do you need to select the cells: what comes
after that ?

Tim

"Scott" wrote in message
...
Hello,

I am having problems selecting all the cells of a worksheet. I am
getting Error 1004.

I have two workbooks. Workbook1 is where the VBA code is running. I
want to select all the cells of the first sheet of Workbook2. After
opening Workbook2, I make it invisible.

In the vba code I call a subroutine and pass it Workbook2.

The following code causes error 1004:

dim ws as worksheet

set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select ***Error happens here

Any help would be greatly appreciated. I am activating the worksheet
in Workbook2 and then trying to select the cells. Does anyone know
why I am getting the error?

Any help would be greatly appreciated. I am totally stuck here.

Thanks,
Scott



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Help with selecting all cells in a sheet -- Error 1004

If the activate works, then just:
Cells.Select
--
Gary''s Student - gsnu200908


"Scott" wrote:

Hello,

I am having problems selecting all the cells of a worksheet. I am
getting Error 1004.

I have two workbooks. Workbook1 is where the VBA code is running. I
want to select all the cells of the first sheet of Workbook2. After
opening Workbook2, I make it invisible.

In the vba code I call a subroutine and pass it Workbook2.

The following code causes error 1004:

dim ws as worksheet

set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select ***Error happens here

Any help would be greatly appreciated. I am activating the worksheet
in Workbook2 and then trying to select the cells. Does anyone know
why I am getting the error?

Any help would be greatly appreciated. I am totally stuck here.

Thanks,
Scott
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with selecting all cells in a sheet -- Error 1004

Tim,

I am opening a lot of workbooks and modifying them. I have them
hidden to speed up the time, so excel is not switching back and forth
between all the windows. Even though they are not visible, I want to
process them.

Scott

On Oct 24, 3:50*pm, "Tim Williams" wrote:
I don't think you can select cells in a hidden workbook.
If the workbook is hidden, why do you need to select the cells: what comes
after that ?

Tim

"Scott" wrote in message

...

Hello,


I am having problems selecting all the cells of a worksheet. *I am
getting Error 1004.


I have two workbooks. *Workbook1 is where the VBA code is running. *I
want to select all the cells of the first sheet of Workbook2. *After
opening Workbook2, I make it invisible.


In the vba code I call a subroutine and pass it Workbook2.


The following code causes error 1004:


dim ws as worksheet


set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select * ***Error happens here


Any help would be greatly appreciated. *I am activating the worksheet
in Workbook2 and then trying to select the cells. *Does anyone know
why I am getting the error?


Any help would be greatly appreciated. *I am totally stuck here.


Thanks,
Scott


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with selecting all cells in a sheet -- Error 1004

For some reason I don't think activate is working.

If I print the value of ActiveWorksheet before the activate statement
and after the activate statement, I get the same value. And, the
value is the name of the worksheet that has the vba code. Not the
sheet that I am trying to activate.

If I just do Cells.select it works. Well, it selects all the cells of
the workbook/worksheet running the code, not of the worksheet i am
trying to activate

On Oct 24, 4:29*pm, Gary''s Student
wrote:
If the activate works, then just:
Cells.Select *
--
Gary''s Student - gsnu200908

"Scott" wrote:
Hello,


I am having problems selecting all the cells of a worksheet. *I am
getting Error 1004.


I have two workbooks. *Workbook1 is where the VBA code is running. *I
want to select all the cells of the first sheet of Workbook2. *After
opening Workbook2, I make it invisible.


In the vba code I call a subroutine and pass it Workbook2.


The following code causes error 1004:


dim ws as worksheet


set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select * ***Error happens here


Any help would be greatly appreciated. *I am activating the worksheet
in Workbook2 and then trying to select the cells. *Does anyone know
why I am getting the error?


Any help would be greatly appreciated. *I am totally stuck here.


Thanks,
Scott
.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Help with selecting all cells in a sheet -- Error 1004

You could just turn off screenupdating instead.
I don't think you can activate a hidden work book.

Try this in the immediate window:

workbooks("PERSONAL.XLS").Activate 'or some hidden workbook
? activeworkbook.Name
Book1 'not the one you want...

Tim


"Scott" wrote in message
...
Tim,

I am opening a lot of workbooks and modifying them. I have them
hidden to speed up the time, so excel is not switching back and forth
between all the windows. Even though they are not visible, I want to
process them.

Scott

On Oct 24, 3:50 pm, "Tim Williams" wrote:
I don't think you can select cells in a hidden workbook.
If the workbook is hidden, why do you need to select the cells: what comes
after that ?

Tim

"Scott" wrote in message

...

Hello,


I am having problems selecting all the cells of a worksheet. I am
getting Error 1004.


I have two workbooks. Workbook1 is where the VBA code is running. I
want to select all the cells of the first sheet of Workbook2. After
opening Workbook2, I make it invisible.


In the vba code I call a subroutine and pass it Workbook2.


The following code causes error 1004:


dim ws as worksheet


set ws = workbook2.sheets(1)
ws.activate
ws.Cells.Select ***Error happens here


Any help would be greatly appreciated. I am activating the worksheet
in Workbook2 and then trying to select the cells. Does anyone know
why I am getting the error?


Any help would be greatly appreciated. I am totally stuck here.


Thanks,
Scott



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime-error 1004 (excel 2007) when selecting validation list optiontriggering worksheet_change property Erik[_11_] Excel Programming 1 April 2nd 09 06:30 PM
unable to protect cells in macro sheet b/c runtime error 1004 rldjda Excel Worksheet Functions 1 March 20th 08 08:28 PM
Runtime Error 1004 on selecting range MaltzMD Excel Programming 5 July 23rd 05 03:33 AM
1004 error when selecting a range Matt J[_2_] Excel Programming 9 July 3rd 04 10:05 PM
Error 1004 when selecting a range Matt J Excel Programming 1 July 3rd 04 06:50 PM


All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"