+ Reply to Thread
Results 1 to 2 of 2

Handling of multiple entries in key cell

  1. #1
    davegb
    Guest

    Handling of multiple entries in key cell

    I have a macro that scans a column of values looking for specific
    numeric codes, i.e. 1, 7, 14, etc. It goes to a vlookup to determine
    where to put a counter for that code. It works great for that. Problem
    is, occasionally, someone has entered multiple codes in the cell, like
    "7,14". I'd like the code to count the 7 and the 14 separately and do
    the steps it normally does for a single value for each of the values.
    Here's the code so far:

    Sub CountMonth()

    Dim lngRsnCode As Long
    Dim wksSrc As Worksheet
    Dim wksMon As Worksheet
    Dim wksTot As Worksheet
    Dim rngCode As Range
    Dim lEndRow As Long
    Dim strMonWksht As String
    Dim dteColCode As Date
    Dim lngCntctMo As Long
    Dim lngMoRow As Long
    Dim strColCode As String
    Dim rngCell As Range

    Const PWORD As String = "2005totals"
    lEndRow = 1000

    Set wksSrc = ActiveSheet '("Barry S")
    Set wksTot = ActiveWorkbook.Sheets("TOTALS")
    Set rngCode = wksSrc.Range("D8:D" & lEndRow)
    wksTot.Unprotect Password:=PWORD

    strMonWksht = wksSrc.Name & " - Monthly"
    Set wksMon = Sheets(strMonWksht)
    wksMon.Range("B4:K15").ClearContents

    For Each rngCell In rngCode
    If rngCell <> 0 Then
    If rngCell <> 11 Then
    If rngCell <> 15 Then

    On Error Resume Next
    dteColCode = rngCell.Offset(0, 5)
    lngCntctMo = Month(dteColCode)
    lngMoRow = lngCntctMo + 3
    lngRsnCode = rngCell
    wksTot.Range("AC1") = lngRsnCode
    strColCode = wksTot.Range("AC2")
    wksMon.Cells(lngMoRow, strColCode) = _
    wksMon.Cells(lngMoRow, strColCode) + 1
    End If
    End If
    End If
    Next rngCell

    wksTot.Protect Password:=PWORD
    wksTot.Select

    End Sub


  2. #2
    davegb
    Guest

    Re: Handling of multiple entries in key cell

    I meant to add before I posted, that it would be much better if there
    were a way to say if it finds these codes (some kind of list), next
    rngCell, but it it contains these codes, do the rest of the procedure.
    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