LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Looping: Selecting elements from a named range to change calcs

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
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
Problem selecting a named range kkknie[_180_] Excel Programming 0 August 11th 04 08:30 PM
Deleting named ranges by looping through range collection agarwaldvk[_11_] Excel Programming 3 August 3rd 04 01:00 AM
Further Help Req'd - Looping thru cells in named range Michael Beckinsale Excel Programming 4 September 2nd 03 08:18 PM
Looping thru cells in a named range Michael Beckinsale Excel Programming 4 September 2nd 03 02:07 PM
looping cells though a named range Jo[_4_] Excel Programming 1 August 20th 03 12:32 AM


All times are GMT +1. The time now is 12:39 AM.

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"