Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 1004 error when selecting a range

I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 1004 error when selecting a range

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 1004 error when selecting a range

I'm using Office 2003

I set the focus to false
AND
added ...

Sheets("SOAUDITSO").Select
== ActiveCell.Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

still get error. Debug indicates 3rd Line (Rows("2:2").Select as location.


"Ron de Bruin" wrote:

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 1004 error when selecting a range

See my reply to one of your posts - there's no need to select.

In article ,
Matt J wrote:

Debug indicates 3rd Line (Rows("2:2").Select as location.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 1004 error when selecting a range

Tried that - didn't work either. If it matters the commandbutton is on a different sheet named (instructions).

"JE McGimpsey" wrote:

See my reply to one of your posts - there's no need to select.

In article ,
Matt J wrote:

Debug indicates 3rd Line (Rows("2:2").Select as location.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 1004 error when selecting a range

Hi Matt

J.E already told you that you don't have to select.
I test your old code with selecting in 2003 and have no problems.



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" wrote in message ...
I'm using Office 2003

I set the focus to false
AND
added ...

Sheets("SOAUDITSO").Select
== ActiveCell.Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

still get error. Debug indicates 3rd Line (Rows("2:2").Select as location.


"Ron de Bruin" wrote:

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 1004 error when selecting a range

Sorry but his suggestion did not work on my machine. Must be something else wrong. I do have Visual Studio 2003 installed, possibly it updated some of the imbedded VBA code causing it to act different, if that is possible.

I will try it on another machine.

"Ron de Bruin" wrote:

Hi Matt

J.E already told you that you don't have to select.
I test your old code with selecting in 2003 and have no problems.



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" wrote in message ...
I'm using Office 2003

I set the focus to false
AND
added ...

Sheets("SOAUDITSO").Select
== ActiveCell.Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

still get error. Debug indicates 3rd Line (Rows("2:2").Select as location.


"Ron de Bruin" wrote:

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 1004 error when selecting a range

Tried both my original code and JE's code on a different machine running Excel 2000. Still get the same erorr.

I am very new to this. Is there something basic I am missing? Please don't assume there is any other code to this axcept the commandbutton.

"Matt J" wrote:

Sorry but his suggestion did not work on my machine. Must be something else wrong. I do have Visual Studio 2003 installed, possibly it updated some of the imbedded VBA code causing it to act different, if that is possible.

I will try it on another machine.

"Ron de Bruin" wrote:

Hi Matt

J.E already told you that you don't have to select.
I test your old code with selecting in 2003 and have no problems.



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" wrote in message ...
I'm using Office 2003

I set the focus to false
AND
added ...

Sheets("SOAUDITSO").Select
== ActiveCell.Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

still get error. Debug indicates 3rd Line (Rows("2:2").Select as location.


"Ron de Bruin" wrote:

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 1004 error when selecting a range

Doesn't for me as long as they're in the same workbook.

In article ,
Matt J wrote:

Tried that - didn't work either. If it matters the commandbutton is on a
different sheet named (instructions).

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 1004 error when selecting a range

GOT IT!

Took your code and set it into a separate public subprocedure ...
Sheets("SOAUDITITEM").Select
Call PubProcedure.pcdrClearSheet
Application.Goto Reference:="R2C1"

I just select the sheets and call the subprocedure.

thanks for your help.

"Ron de Bruin" wrote:

Hi Matt

J.E already told you that you don't have to select.
I test your old code with selecting in 2003 and have no problems.



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" wrote in message ...
I'm using Office 2003

I set the focus to false
AND
added ...

Sheets("SOAUDITSO").Select
== ActiveCell.Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

still get error. Debug indicates 3rd Line (Rows("2:2").Select as location.


"Ron de Bruin" wrote:

Hi Matt

If you use Excel 97?

This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Matt J" <Matt wrote in message ...
I have the follwoing code in a macro and it works fine

Sheets("SOAUDITSO").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

When I copy it to a ClickEvent for a command button it returns a Run-time 1004 error "Select method of Range class failed"

I'M new to VBA and please excuse me for being so naive






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
Error 1004 using Shapes.Range().Align juergen Excel Programming 3 June 25th 04 11:14 AM
Error 1004 when defining range by cells(r,c) format dave Excel Programming 8 May 18th 04 08:51 PM
Range.Copy and error 1004 Carl Rapson Excel Programming 5 November 15th 03 03:21 AM
Run-time 1004 error on range select Morgan[_3_] Excel Programming 3 November 11th 03 11:44 PM
Range.cells.calculate give error 1004 only in XP Stef[_3_] Excel Programming 1 October 31st 03 02:57 PM


All times are GMT +1. The time now is 07:53 PM.

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"