Results 1 to 3 of 3

Having trouble creating a button that counts when two strings are side-by-side

Threaded View

  1. #1
    Registered User
    Join Date
    07-29-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    16

    Having trouble creating a button that counts when two strings are side-by-side

    Hi everyone,

    I am completely new to Excel VBA so I am really hoping I can get some help *thank you in advance*.

    I have an excel worksheet that has different string values in the cells and I have to specifically count when the values "NSW" are found beside each other (i.e. NSW, NSW) in the excel sheet. I have only created a function so far (not sure if it is right...) but I I really need to do is create a command button that would show the results of the count in a message box, but I am stuck. Any help would be greatly appreciated!

    Here is what I have so far:

    Function CountIfAll(Crit1, Crit2, Rng As Range) As Long
    Dim rCell As Range
        
        CountIfAll = 0
        
        For Each rCell In Rng
            If rCell = Crit1 And rCell.Offset(, 1) = Crit2 Then
                CountIfAll = CountIfAll + 1
            End If
        Next rCell
    End Function
    Last edited by alansidman; 08-18-2014 at 04:10 PM. Reason: code tags added

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Set Excel 2010 as default program when installed side-by-side with 2013
    By AlvaroSiza in forum Excel General
    Replies: 1
    Last Post: 08-31-2013, 06:45 PM
  2. VBA to copy data from multiple sheets side-by-side into one sheet matching date
    By MHCapcog in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-02-2013, 06:11 PM
  3. Replies: 0
    Last Post: 04-19-2009, 10:53 PM
  4. Creating stacked graphs side-by-side
    By yssem in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-14-2006, 07:18 AM
  5. Replies: 1
    Last Post: 03-20-2006, 10:15 PM

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