+ Reply to Thread
Results 1 to 5 of 5

Dynamic Ranges

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Dynamic Ranges

    Hello,

    I know that I can use this line of code to find a range and the last value of the column.

    Set Range = Range("B11", Range("B" & Rows.count).End(xlUp))

    Is there a way to do this with out using "B"? For example, I would like "B" to be a variable that goes through a loop and is updated.

    Thank you, Natalie

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Dynamic Ranges

    What are you looping through?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Dynamic Ranges

    What I would like to do (I think) is use a while loop. If a particular condition passes, I would like to update the column number and check a different column for a maximum value. The columns I need to check are eight columns apart, so I would update a variable.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Dynamic Ranges

    You can simply make "B" a variable?

    Dim mycol As String
    Dim myrange As Range
    mycol = "B" 'or however you want to assign the variable's value
    Set myrange = Worksheets("Sheet1").Range(mycol & "11", Range(mycol & Rows.Count).End(xlUp))
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Dynamic Ranges

    Thank you for your response.

    I am trying that. I have many columns of data. Each are 8 columns apart. In a summary file, I'd like to to put the maximum value of each column in a new column. So far it isn't work. Here is my code if you can take a look at it.

    
    Dim n As Integer
    Dim m As Integer
    Dim i As Integer
    Dim Cell As String
    Dim idss As Double
    Dim col As Integer
    Dim vbrRange As Range
    
    
    
    n = 2                   'start with column B
    i = 11                  'first row in column reticle
    m = 3
    col = 1
    
    Cell = ActiveWorkbook.Sheets("Idss").Cells(1, n).Value
    idss = ActiveWorkbook.Sheets("Idss").Cells(126, 3).Value
    
    Sheets("Idss").Activate
    Set vbrRange = Sheets("Idss").Range(col & "11", Range(col & Rows.count).End(xlUp))
    
    While Cell <> ""
        
        Cells(i, 1) = Cell
        Cells(i, 2) = Application.WorksheetFunction.Max(vbrRange)
        n = n + 8
        col = col + 8
       Set vbrRange = Sheets("Idss").Range(col & "11", Range(col & Rows.count).End(xlUp))
        Cell = ActiveWorkbook.Sheets("Idss").Cells(1, n).Value
        
        i = i + 1
    
        
    Wend

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. dynamic ranges
    By excelnerd1 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-07-2009, 01:51 PM
  2. Dynamic Ranges
    By TheRevelator in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-01-2008, 08:41 AM
  3. name dynamic ranges with VBA
    By robotlust in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2008, 01:04 PM
  4. Dynamic Ranges
    By NickNole in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2008, 01:08 PM
  5. [SOLVED] Dynamic Formulas with Dynamic Ranges
    By Ralph Howarth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-21-2005, 05:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1