+ Reply to Thread
Results 1 to 3 of 3

Range and Cells method

  1. #1
    Jenny
    Guest

    Range and Cells method

    I am trying to build a range using the following method;

    CntRef4 = xlApp.Range(xlApp.Cells(RowRef, ColRef), xlApp.Cells(z, ColRef))

    Where CntRef is Range, RowRef,ColRef and z are String. RowRef,ColRef and z
    all contain values when I do a mouse over, however CntRef =Nothing. If I
    Change CntRef to String it reads =""

    How should I look to clear upo this problem

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    z, RowRef and ColRef all need to be integers (or double)

  3. #3
    Robin Hammond
    Guest

    Re: Range and Cells method

    Jenny,

    You are missing a set statement for one thing. See the example below which
    has made the data typing a bit more obvious and uses numeric data types.

    Sub SetRange()
    Dim XL As Excel.Application
    Dim rngWanted As Range
    Dim lRow As Long
    Dim nCol As Integer
    Dim lRow2 As Long

    Set XL = GetObject(, "Excel.Application")
    lRow = 1
    nCol = 1
    lRow2 = 2

    With XL
    Set rngWanted = .Range(.Cells(lRow, nCol), .Cells(lRow2, nCol))
    End With
    Debug.Print rngWanted.Address
    End Sub

    Robin Hammond
    www.enhanceddatasystems.com

    "Jenny" <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to build a range using the following method;
    >
    > CntRef4 = xlApp.Range(xlApp.Cells(RowRef, ColRef), xlApp.Cells(z, ColRef))
    >
    > Where CntRef is Range, RowRef,ColRef and z are String. RowRef,ColRef and z
    > all contain values when I do a mouse over, however CntRef =Nothing. If I
    > Change CntRef to String it reads =""
    >
    > How should I look to clear upo this problem




+ 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