Data not shown in remaining rows

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi All,
I need to have the cells from row 3 till the last row in Column B to show preset details but my code gets data in row 3 only. Please help to review what should be corrected.

VBA Code:
Sub Sum18()

    Dim rng As Range
    Dim rngRow As Range
    Dim c As Range
    Dim lastrow As Long
    Dim lastcol As Long
    Dim rngCol As Range, rngColRow As Range
    Dim vDayB As Date, vDayE As Date
    Dim vColumnB As Range, vColumnE As Range
    
    ActiveWindow.ScrollColumn = 2
    
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
    
     Set rng = Range(Cells(1, 1), Cells(lastrow, lastcol))
     Set rngCol = rng.Columns(2)
     Set rngColRow = rngCol.Rows(3)
          Debug.Print rngCol.Address
        
        'Find the 1st and last date of month
         vDayB = CDate(Format(ActiveSheet.Name, "0000-00"))
         vDayE = DateAdd("m", 1, vDayB) - 1

        'Find these dates in the range of the dates in the first row
         Set vColumnB = rng.Rows(1).Find(vDayB, , xlFormulas)
         Set vColumnE = rng.Rows(1).Find(vDayE, , xlFormulas)
        
         Debug.Print vColumnB.Address, vColumnE.Address
        
                
        For Each c In rngColRow.Cells
        
        Dim strtot As String, strlve As String, strday As String, streve As String, strnte As String
        
            'Find the 1st and last date of month
              vDayB = CDate(Format(ActiveSheet.Name, "0000-00"))
              vDayE = DateAdd("m", 1, vDayB) - 1
              
            'find network days
            Dim vLastRowHo As Long
            vLastRowHo = Worksheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
            HolidayList = Worksheets("Data").Range("A2:A" & vLastRowHo).Value
            strtot = Application.NetworkDays(vDayB, vDayE, HolidayList)

                  
            strlve = 2
            strday = Application.CountIf(Range(c.Cells(, vColumnB.Column), c.Cells(, vColumnE.Column)), "G")
            streve = 4
            strnte = 5
        
        
        Debug.Print strday
                
        c = "T:" & strtot & " L:" & strlve & " D:" & strday & " E:" & streve & " N:" & strnte
              
        Next c

End Sub
 

Attachments

  • sum error.png
    sum error.png
    22.9 KB · Views: 12
Hi EXCEL MAX,
Initial test seems work but it does not calculate the first day value !!
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi EXCEL MAX,
I hardly managed the job done in standard module and will try the Worksheet Calculate module. I need help to continue the remaining work of this function, please if you have time to review my another thread "Change Cells' color if sum items match" cos I think you will know better than others. Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,812
Members
449,339
Latest member
Cap N

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top