Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Udo.
Thanks for this: I'll study the syntax and adapt as necessary. REgards Phil "Udo" wrote: If your data are given in a consistent list (i.e. no empty lines between them), then you could apply the following function: Function LastRow _ (objSheet As Worksheet, _ strStartCell As String) As Range Dim objRange As Range Dim lngLastRow As Long Dim lngLastCol As long Set objRange = objSheet _ .Range(strStartCell).CurrentRegion lngLastRow = objrange.Row + _ objRange.rows.count - 1 lngLastCol = objRange.Column + _ objRange.columns.Count - 1 With objSheet Set Lastrow = .Range _ (.Cells(lngLastRow, objRange.Column), _ .Cells(lngLastRow, lngLastCol)) End with End Function You call the function from within your previous code by just entering its name followed by the required information like Rows = LastRow(Sheets("Variable List"), "C3").select That would require, that you have that variable list copied into a sheet within your active workbook named "Variable List". If this list is in another workbook (assume it is ListFile.xls stored in c:\Temp), the code would be something like: Dim ListSource as Workbook <main code here set ListSource = workbooks.Open("c:\temp\ListFile.xls") rows = LastRow(ListSource.Worksheets("Variable List"), "C3").select Then, in the code we had established before, you would write: For counter = 1 to Rows ...... With that you should be able to cope with your problem. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem selecting a named range | Excel Programming | |||
Deleting named ranges by looping through range collection | Excel Programming | |||
Further Help Req'd - Looping thru cells in named range | Excel Programming | |||
Looping thru cells in a named range | Excel Programming | |||
looping cells though a named range | Excel Programming |