LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default What did I do? (Select Method of Range Class Failed )

Hi Rod

The best approach, in my opinion, when referencing a worksheet object is to
use the object name. This is Sheet1, Sheet2 etc for sheets and is created
when the sheet is added. You can change these in the VB editor in the
properties window. These names can only be changed here and it doesn't
matter what the sheet name is.

For example

The first worksheet created will have the object name Sheet1 regardless of
where it is in the actual order. It may have a worksheet name (shown on the
tab) of Data. I usually rename (using the name property of the object) this
sheet wsData and then reference the object directly. e.g.
wsData Range("a1").copy

Hope this helps.
Nick

"HotRod" wrote in message
...
Jim
Just a question since this really has been what I'm wondering

1) If I use Sheet1 instead of Worksheet("SheetName") are all of the sheets
labeled sequentialy from Sheet1 - Sheet100, and what happens if someone
changes the order of the worksheets?

2) I've now replaced the code
Application.Worksheet("SheetName").Range() etc.

with

Rng.Range() etc.

In the code below would it make more sense to create to Range Objects?

'COPY MAINSHEET TO
WORKSHEET --------------------------------------------------------------------------------------------------
'Select Range on first Sheet and then copy Values only.

Set Rng = Worksheets(SheetName).UsedRange.Rows

'Clear old sheet first
Application.Worksheets(SheetName2).Range("A" & WorkSheet_First_Row,
"Z55500").Value = ""

'COPY DATA
Application.Worksheets(SheetName2).Range("A2", "G" & (Rng.Rows.Count -
(First_Row - WorkSheet_First_Row))).Value = _
Application.Worksheets(SheetName).Range("A" & First_Row, "G" &
Rng.Rows.Count).Value






 
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
Select method of Range class failed - but why??? Orion[_2_] Excel Programming 3 December 21st 04 03:28 PM
select method of range class failed Joseph[_40_] Excel Programming 0 September 28th 04 04:08 PM
select method of range class failed Joseph[_38_] Excel Programming 1 September 28th 04 03:21 PM
select method of range class failed Joseph[_39_] Excel Programming 0 September 28th 04 02:32 PM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


All times are GMT +1. The time now is 08:19 PM.

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

About Us

"It's about Microsoft Excel"