![]() |
drop first row in range and return a new range object
Hi I'm trying to create a function that will drop the first row in a given
range object and return a new range object - to eliminate headers from a range object. so something like this??? Function dropFirstCell(ByVal r As Range) As Range Dim r2 As Range Dim i As Integer i = 2 Set r2 = r.Range(Cells(i), Cells(r.Rows.Count)) Set dropFirstCell = r2 End Function can anyone help? |
drop first row in range and return a new range object
We build the output range one cell at a time:
Function rout(rin As Range) As Range Set r1 = rin.Cells(1, 1) rw1 = r1.Row Set rout = Nothing For Each rr In rin If rr.Row = rw1 Then Else If rout Is Nothing Then Set rout = rr Else Set rout = Union(rout, rr) End If End If Next End Function Sub tester() Dim r As Range Set r = Range("A1:F7") MsgBox (rout(r).Address) End Sub -- Gary''s Student - gsnu200814 "Rik" wrote: Hi I'm trying to create a function that will drop the first row in a given range object and return a new range object - to eliminate headers from a range object. so something like this??? Function dropFirstCell(ByVal r As Range) As Range Dim r2 As Range Dim i As Integer i = 2 Set r2 = r.Range(Cells(i), Cells(r.Rows.Count)) Set dropFirstCell = r2 End Function can anyone help? |
All times are GMT +1. The time now is 12:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com