Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-03-2018, 08:24 AM
Divinedar Divinedar is offline Variable for Date not working Windows 7 64bit Variable for Date not working Office 2010 64bit
Novice
Variable for Date not working
 
Join Date: Jun 2016
Posts: 21
Divinedar is on a distinguished road
Default Variable for Date not working

I have the following codes



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

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
                For i = 2 To 30 'update with max row
                    If sht.Cells(i, 2) = strField Then
                        PrjByMonth = PrjByMonth + CDbl(sht.Cells(i, j))
                        GoTo nxtSht
                    End If
                Next i
            End If
        Next j
    End If
 
nxtSht: Next
 
End Function

Public Sub ViewPrjByMth()
Dim strField As String, pMonth As Date
Worksheets("PrjByMth").Visible = True
Sheets("PrjByMth").Activate
PrjByMonth strField, pMonth
End Sub
I attached a picture of the results that I'm getting that I just can't figure out why this line "If sht.Cells(1, j) = pMonth Then" is not giving me the correct information. Please help.
Attached Images
File Type: png Temp.png (179.8 KB, 31 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable shimulsiddiquee Excel 1 05-16-2017 07:39 AM
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge Berryblue Mail Merge 1 11-13-2014 05:36 PM
Variable for Date not working Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM
Variable for Date not working Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM
30+ days Variable Day Date Calculations via Fields ztag Word 2 01-06-2012 11:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft