LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Trouble cutting a range of cells

When running the below sub, I am receiving the following error:
Compile error:
Wrong number of arguments or invalid property assignment

I am trying to move a range of cells in order by a subtotal, which could vary.
To move the cells, I am trying to do a cut and insert before swapping the
array elements.
pGroup(x,0) = cell row of group
pGroup(x,1) = string value of no importance for this exercise
pGroup(x,2) = Subtotal (number of entries(rows) within the group)

Once the cells are moved, the Array Elements will be swapped.
With the exception of the cell row, which will be recalculated for x.

Any help will be greatly appreciated.

Sub OrderBySubtotal()

Dim iBegin As Integer
Dim iEnd As Integer
Dim x As Integer
Dim y As Integer
Dim rSelection As Integer
Dim iTempRow As Integer
Dim sTempGroup As String
Dim iTempTotal As Integer

iBegin = LBound(pGroups) + 1
iEnd = UBound(pGroups)

For x = iBegin To iEnd - 1
For y = iBegin + 1 To iEnd
If pGroups(x, 2) < pGroups(y, 2) Then
'Getting error here
pWorksheet.Range(Cells(pGroups(y, 0), 1),
Cells(pGroups(y, 0) + pGroups(y, 2)), 10).Cut
pWorksheet.Range(Cells(pGroups(x, 0), 1)).Insert
Shift:=xlDown
iTempRow = pWorksheet(y, 0)
sTempGroup = pWorksheet(y, 1)
iTempTotal = pWorksheet(y, 2)
pGroups(y, 0) = pWorksheet(x, 0)
pGroups(y, 1) = pWorksheet(x, 1)
pGroups(y, 2) = pWorksheet(x, 2)
pWorksheet(x, 0) = Int(iTempRow) + Int(pWorksheet(y, 0))
+ 1
pWorksheet(x, 1) = sTempGroup
pWorksheet(x, 2) = iTempTotal
End If
Next y
Next x
End Sub
 
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
trouble with lookup in a range of cells. evilthorne Excel Worksheet Functions 5 September 28th 09 02:16 AM
Cutting and Pasting Cells into a shape or textbox Gator Excel Discussion (Misc queries) 4 July 14th 08 08:21 PM
How do I freeze formulas when cutting and pasting other cells? thunderstix33 Excel Worksheet Functions 1 June 3rd 08 06:57 PM
Selecting and cutting unknown picture numbers from a specifc range of cells [email protected] Excel Programming 3 October 29th 07 09:09 PM
Protection, cutting cells Bryce Excel Discussion (Misc queries) 0 February 26th 07 03:11 AM


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