Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Range referencing incorrectly

I seem to be missing how to reference celles properly, any help appreciated:

Dim i As Integer
For i = maxrows To 2 Step -1
Range("cells(i,1):cells(i,2)").Select
Selection.Cut Destination:=Range("cells(i-1,3):cells(i-1,4)")
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Range referencing incorrectly

On 16 nov, 01:11, Bob Zimski
wrote:
I seem to be missing how to reference celles properly, any help appreciated:

* Dim i As Integer
* For i = maxrows To 2 Step -1
* * Range("cells(i,1):cells(i,2)").Select
* * Selection.Cut Destination:=Range("cells(i-1,3):cells(i-1,4)")
* Next i


Hello,

It seems to be Range(cells(i,1),cells(i,2)").Select instead of Range
("cells(i,1):cells(i,2)").Select

Hope this helps

Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Range referencing incorrectly

You could use:

Range(cells(i,1),cells(i,2)).Select

or

cells(i,1).resize(1,2).select
(resize that cell in column A to 1 row by 2 columns.

so

Dim i As Long
Dim maxrows As Long
maxrows = 5 'for testing
For i = maxrows To 2 Step -1
Cells(i, 1).Resize(1, 2).Cut _
Destination:=Cells(i - 1, 3)
Next i

Excel will resize the destination range. Just like if you did it manually, you
could just select the topleft cell of the destination range.



Bob Zimski wrote:

I seem to be missing how to reference celles properly, any help appreciated:

Dim i As Integer
For i = maxrows To 2 Step -1
Range("cells(i,1):cells(i,2)").Select
Selection.Cut Destination:=Range("cells(i-1,3):cells(i-1,4)")
Next i


--

Dave Peterson
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
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Incorrectly getting "Subscript out of range" Error. Andrew[_55_] Excel Programming 4 April 30th 07 08:45 AM
range referencing lakey13[_5_] Excel Programming 1 November 9th 04 04:03 PM
range referencing lakey13[_4_] Excel Programming 0 November 9th 04 03:38 PM


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