Results 1 to 7 of 7

Cells Method using Ranges

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    38

    Cells Method using Ranges

    Hello, all,

    I am working with the below code. I did not write the code, but I am commenting it so that others can understand what each line is doing (we are hiring a new person that has limited coding experience).

    I would like to understand how rowRng is used in the code. Specifically, why does the Cells property remain unchanged (e.g. Cells(1,2) never changes), but rowRng changes? The code moves from one row to the next, so I don't understand why the Cells property isn't something like, Cells(x,2), where x changes with each loop. uniquecount is a function used to count the number of unique values in the column.

    Here is the code:

    Dim mapRng As Range
    Dim tblQuestion As Range
    Dim rowRng As Range

    For Each rowRng In mapRng.Rows
    If rowRng.Cells(1, 2) = "X" Then
    rowRng.Cells(1, 3) = "X"
    rowRng.Cells(1, 4) = "X"

    Else
    If rowRng.Cells(1, 2) > 0 And rowRng.Cells(1, 2) < 10000000 Then
    If tblQuestion.Columns(1).Find(rowRng.Cells(1, 2)).Offset(0, 3) <> "" Then
    rowRng.Cells(1, 3) = "QL"

    Else
    rowRng.Cells(1, 3) = "OPEN"
    End If

    Else
    rowRng.Cells(1, 3) = "DEMO"
    End If

    If rowRng.Cells(1, 3) = "DEMO" Then
    rowRng.Cells(1, 4) = rowRng.Cells(1, 2)

    Else
    If uniquecount(rowRng.Cells(1, 2), mapRng) = 1 Then
    rowRng.Cells(1, 4) = "Main"

    Else
    rowRng.Cells(1, 4) = "TRANSPOSE"

    End If
    End If
    End If
    Next rowRng
    Last edited by montanaheather; 11-08-2012 at 02:13 PM.

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