View Single Post
 
Old 04-06-2018, 11:08 AM
Divinedar Divinedar is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jun 2016
Posts: 21
Divinedar is on a distinguished road
Default Variable for Date not working

Wanted you to see my final code:

HTML Code:
Function PrjByMonth(strField As String, pMonth As Date)
Dim sht As Worksheet, i As Long, j As Integer
'Application.Volatile

PrjByMonth = 0
 
 
 
For Each sht In ActiveWorkbook.Sheets
    If Mid(sht.Name, 1, 2) = "FY" Then
        For j = 3 To 14 'The row of dates. Starts at C1 to N1
        
            If sht.Cells(1, j) = pMonth Then 'This says ROW 1,COLUMNS C THRU N
                For i = 2 To 30 'This says ROWS 2 THRU 30
                    If sht.Cells(i, 2) = strField Then ' This is ROWS 2 THRU 30, COLUMN B
                        PrjByMonth = PrjByMonth + sht.Cells(i, j)
                        GoTo nxtSht
                    End If
                Next i
            End If
        Next j
    End If
 
nxtSht: Next
 
End Function

Public Sub ViewPrjByMth()

Application.ScreenUpdating = False

Sheets("PrjByMth").Range("B2:BI50").Clear

With Sheets("PrjByMth").Range("B2:BI50")
  .FormulaR1C1 = "=IF(ISBLANK(RC1),0,IF(ISBLANK(R1C),0,prjbymonth(RC1,R1C)))"
  .Value = .Value
  .NumberFormat = "_($* #,##0_);_($* (#,##0);_($* ""-""_);_(@_)"
End With
BoldHighHours

Application.ScreenUpdating = True
End Sub
Sub BoldHighHours()

    Application.ScreenUpdating = False
    Dim c As Range

    For Each c In Range("B2:BI50")

        If c.Value >= 10 Then
            c.Font.Bold = True
            c.Interior.ColorIndex = 3
        Else
            c.Font.Bold = False
            c.Interior.ColorIndex = False
        End If

    Next
    Application.ScreenUpdating = True

End Sub
This works perfectly. I have more to do and if you don't mind helping me I would love to reach out to you at anytime? Thank you again
Reply With Quote