+ Reply to Thread
Results 1 to 4 of 4

Refer to Ranges using Cells notation

  1. #1
    Scott P
    Guest

    Refer to Ranges using Cells notation

    Hi,

    I am trying to pass through a worksheet using VBA with a nested For loop and
    would like to refer to the cells that I pass through using the Cells(row,
    col) notation. Is there a way to refer to a range of cells (e.g. A1:A100)
    using the Cells(row, col) notation instead of having to use the Range
    notation?

    Thanks in advance.

  2. #2
    Alan Beban
    Guest

    Re: Refer to Ranges using Cells notation

    There are several ways. One is

    Set rng = Range("A1")
    MsgBox Range(rng(1),rng(100)).Address

    It will display $A$1:$A$100

    Alan Beban

    Scott P wrote:
    > Hi,
    >
    > I am trying to pass through a worksheet using VBA with a nested For loop and
    > would like to refer to the cells that I pass through using the Cells(row,
    > col) notation. Is there a way to refer to a range of cells (e.g. A1:A100)
    > using the Cells(row, col) notation instead of having to use the Range
    > notation?
    >
    > Thanks in advance.


  3. #3
    Scott P
    Guest

    RE: Refer to Ranges using Cells notation

    I believe that I have found the answer to my own question, so I am posting it
    here. It appears Excel allows you to refer to ranges of cells using the
    "cells" notation using syntax such as this:

    Set rng = Range(Cells(1, 1), Cells(1, 100))



    "Scott P" wrote:

    > Hi,
    >
    > I am trying to pass through a worksheet using VBA with a nested For loop and
    > would like to refer to the cells that I pass through using the Cells(row,
    > col) notation. Is there a way to refer to a range of cells (e.g. A1:A100)
    > using the Cells(row, col) notation instead of having to use the Range
    > notation?
    >
    > Thanks in advance.


  4. #4
    Tim Williams
    Guest

    Re: Refer to Ranges using Cells notation

    with activesheet
    set rng = range(.cells(1,1),.cells(100,1))
    'or
    set rng = .cells(1,1).resize(100,1)
    end with

    Tim

    "Scott P" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I am trying to pass through a worksheet using VBA with a nested For
    > loop and
    > would like to refer to the cells that I pass through using the
    > Cells(row,
    > col) notation. Is there a way to refer to a range of cells (e.g.
    > A1:A100)
    > using the Cells(row, col) notation instead of having to use the
    > Range
    > notation?
    >
    > Thanks in advance.




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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