Data pulling from Combo box is for a specific date, not a Month rollup

SouthernAngel

New Member
Joined
Oct 8, 2018
Messages
1
I am needing assistance with adjusting my combo box to allow the data to update based on the month selected. Currently, it is only pulling data for the day (i.e. if "October" is selected, it is only pulling "10/1/2018")

To start, I have a VBA code below. It inputs data from a spreadsheet into the Data tab on the workbook attached. The VBA code is setup to have the date entered as "mmmm-yyyy" but when inputting on the Data tab, it displays as "October-2018", however it is formatted to input the day the data was entered from another spreadsheet.

On the Overview tab, when October is selected, the idea is to update all the data based on that selectin, however it is only pulling that specific day.
NOTE: I am using October because there were three days of input

How do I setup my Data Validation list to incorporate the month of October?

Code:
Sub CopyData()

   Dim i As Long
   Dim Rng As Range
   Dim Iws As Worksheet, Rws As Worksheet
   
   Set Iws = Sheets("Input")
   Set Rws = Sheets("AuditData")
   For i = 3 To 11
      For Each Rng In Iws.Cells(4, i).Resize(21).SpecialCells(xlConstants).Areas
         With Rws.Range("D" & Rows.Count).End(xlUp).Offset(1)
            .Value = Rng.Offset(, -i + 1).Value
            .Offset(, -3).Resize(, 3).Value = Array(Date, Application.UserName, Iws.Range("J1").Value)
            .Offset(, -3).NumberFormat = "mmmm-yyyy"
            .Offset(, 1).Value = Iws.Cells(3, i).Value
            .Offset(, 2).Resize(, Rng.Count).Value = Application.Transpose(Rng.Value)
            .Offset(, 6).FormulaR1C1 = "=AVERAGE(rc6:rc9)"
         End With
      Next Rng
   Next i
         
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you want the date to really only be "October" and not the day it was entered you could try something like this:
Code:
.Offset(, -3) = .Offset(, -3) - Day(.Offset(, -3)) + 1

this says take the date in the field, subtract the number of days in the date, (which will put it on the last day of the previous month) and then add 1 to get back to the first of the month.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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