colum rows problem in excel

A

alex.simms

how can I select a range of cells in column of data which is 3 x column's
wide and the no. of rows varies from 100 to 5000.
what I want to do is split the range into 2, select the bottom half of the
original range, and move to another sheet
 
J

Jim Cone

Alex,

Your question is pretty general, so the following may get you
started or it may not...

'========================================
Sub CallRange()
'Displays address of revised range.
'You can replace "Selection" with the actual Range object.
MsgBox ManageRange(Selection).Address
End Sub

'========================================
'Resizes the specified range. Always uses three columns.
'Removes blank rows below the last cell with data.
Function ManageRange(ByRef objColumns As Range) As Range
Dim objRng As Range
Dim lngRows As Long

'Call function to determine last row with data.
lngRows = GetBottomRow(objColumns)
lngRows = lngRows - objColumns.Row + 1

'Resize
Set objRng = objColumns.Resize(lngRows, 3)
Set ManageRange = objRng

Set objRng = Nothing
End Function

'==========================================
' Returns the number of the last worksheet row with data.
' If the sheet is blank it returns 0.
'==========================================
Function GetBottomRow(ByRef objRange As Range) As Long
On Error GoTo NoRow
' LINE BELOW IS OPTIONAL
If objRange.Parent.FilterMode Then objRange.Parent.ShowAllData

GetBottomRow = objRange.Find(what:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Exit Function
NoRow:
GetBottomRow = 0
End Function
'==========================================

Regards,
Jim Cone
San Francisco, CA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top