Results 1 to 5 of 5

Thread: Identifying Zero-to-Non-Zero Value and vice versa

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Here's a VBA solution

    Code:
    Function fPhaseInOutMonth(rngSource As Range) As Long
    
        Dim lngCol As Long: lngCol = rngSource.Columns.Count
        If rngSource(1, lngCol).Value = 0 Then
            For lngCol = lngCol - 1 To 1 Step -1
                If rngSource(1, lngCol).Value <> 0 Then
                    fPhaseInOutMonth = lngCol + 1
                    Exit Function
                End If
            Next lngCol
        Else
            For lngCol = lngCol - 1 To 1 Step -1
                If rngSource(1, lngCol).Value = 0 Then
                    fPhaseInOutMonth = lngCol + 1
                    Exit Function
                End If
            Next lngCol
        End If
        fPhaseInOutMonth = 1
        
    End Function
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 8
    Last Post: 09-04-2014, 02:45 AM
  2. Need VBA code to convert csv to xlsx and vice versa
    By Pravee89 in forum Excel Help
    Replies: 1
    Last Post: 10-13-2012, 11:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •