Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Range selection not working

hi
Iam using officeXP and the following VBA code is not working in EXCEL. I would greatly appreciate if somebod
can tell me the correct way to do this code. I get 'select method of range class failed" error message

' here is the cod
dim cvalue as intege
cvalue=
Worksheets("sheet2").Selec
Range(Cells(cvalue, 1), Cells(cvalue, 54)).Selec
Selection.Cop
Sheets("Sheet3").Selec
Rows("2:2").Selec
ActiveSheet.Past

' end of cod

thank
Kana
Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Range selection not working

Hi Kanan,

You are not mapping the source onto the same size target. The problem is in
the Rows("2:2")

So instead of

Rows("2:2").Select

you could use

Range("A2").Select

which will copy into A2 across

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kanan" wrote in message
...
hi,
Iam using officeXP and the following VBA code is not working in EXCEL. I

would greatly appreciate if somebody
can tell me the correct way to do this code. I get 'select method of range

class failed" error message.


' here is the code
dim cvalue as integer
cvalue=4
Worksheets("sheet2").Select
Range(Cells(cvalue, 1), Cells(cvalue, 54)).Select
Selection.Copy
Sheets("Sheet3").Select
Rows("2:2").Select
ActiveSheet.Paste

' end of code

thanks
Kanan
Any ideas?





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Range selection not working

Thank You Bob. That worked great

But I am still not sure why Rows("2:2") is not the same as Range("A2").
I guess my understanding of the Rows is not correct. can you please explain
thank
Kanan
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Range selection not working

Hi Kanan,

Rows("2:2") refers to the whole row, al 256 cells. You are copying 54 cells,
and when you try to paste 54 onto 256, you get an error. But if you try and
paste 54 onto 1 (which Range("A2") is, it copies across or down the
requisite number of cells, as in the source.

The same happens in Excel,. Select A1:J1 and copy. Then select row 5 and try
and paste, you will get an error. Select A5 and paste, and you will see it
paste all the way across to J5.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kanan" wrote in message
...
Thank You Bob. That worked great.

But I am still not sure why Rows("2:2") is not the same as Range("A2").
I guess my understanding of the Rows is not correct. can you please

explain?
thanks
Kanan



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
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Ctrl-Space Column Selection No Longer Working MPW Excel Discussion (Misc queries) 11 November 22nd 06 06:07 PM
Selection.count isnt working No Name Excel Programming 2 February 8th 04 03:23 PM
Creating range name for a range selection Mervyn Thomas Excel Programming 1 January 26th 04 05:18 PM


All times are GMT +1. The time now is 01:43 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"