Trying to Get a button to auto populate cells in a budget calendar I created

scottyb1977

New Member
Joined
May 22, 2015
Messages
8
I'm still new to VBA, Took a long break and started studying C++, so now I'm all confused as to how to get this done in VBA. So here is an image of the file. I have my bills located on the same sheet Starting at B76:D100, B76,C76, and D76 are titles Date, Item, Amount The Date is a formula.. As you can see A13 is also a formula and D13 is a different formula not sure if that makes a difference or not. I want to input this info into the calendar with a button kind of like a bank ledger on each day and I want the button to be able to auto populate all the reoccurring bills each month, and I want to input my bills into rows 16 to rows 22 where the dates match. Some will have multiple entries where there is multiple bills on the same day. Any help is greatly appreciated. Thanks in Advance!
Budget Calendar2.0.1.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
9 Select Month:FebruaryYear: 2022
10February 2022
11Starting Balance:$0.00
12SundayMondayTuesdayWednesdayThursdayFridaySaturday
1330$0.0031$0.0001$0.0002$0.0003$0.0004$0.0005$0.00
14PayItemAmountTotalPayItemAmountTotalPayItemAmountTotalPayItemAmountTotalPayItemAmountTotalPayItemAmountTotalPayItemAmountTotal
15$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00
16       
17       
18       
19       
20       
21       
22       
Sheet1
Cell Formulas
RangeFormula
A10A10=V9&" "&AA9
A13A13=Start-(WEEKDAY(Start)-1)
D13,AB13,X13,T13,P13,L13,H13D13=IF(C15="","",LOOKUP(2,1/(D15:D22<>""),D15:D22))
E13,Y13,U13,Q13,M13,I13E13=IF(A13<>"",A13+1,$Y1+1)
D15D15=IF(C15="","",IF(A15="P",$Y$11+C15,Y11-C15))
AB16:AB22,X16:X22,T16:T22,P16:P22,L16:L22,H16:H22,D16:D22D16=IF(C16="","",IF(A16="P",D15+C16,D15-C16))
H15,AB15,X15,T15,P15,L15H15=IF(G15="","",IF(E15="P",D13+G15,D13-G15))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
Z22:AB22Expression=$Y$22="X"textNO
Z21:AB21Expression=$Y$21="X"textNO
Z20:AB20Expression=$Y$20="X"textNO
Z19:AB19Expression=$Y$19="X"textNO
Z18:AB18Expression=$Y$18="X"textNO
Z17:AB17Expression=$Y$17="X"textNO
Z16:AB16Expression=$Y$16="X"textNO
Z15:AB15Expression=$Y$15="X"textNO
V22:X22Expression=$U$22="X"textNO
V21:X21Expression=$U$21="X"textNO
V20:X20Expression=$U$20="X"textNO
V19:X19Expression=$U$19="X"textNO
V18:X18Expression=$U$18="X"textNO
V17:X17Expression=$U$17="X"textNO
V16:X16Expression=$U$16="X"textNO
V15:X15Expression=$U$15="X"textNO
R22:T22Expression=$Q$22="X"textNO
R21:T21Expression=$Q$21="X"textNO
R20:T20Expression=$Q$20="X"textNO
R19:T19Expression=$Q$19="X"textNO
R18:T18Expression=$Q$18="X"textNO
R17:T17Expression=$Q$17="X"textNO
R16:T16Expression=$Q$16="X"textNO
R15:T15Expression=$Q$15="X"textNO
N22:P22Expression=$M$22="X"textNO
N21:P21Expression=$M$21="X"textNO
N20:P20Expression=$M$20="X"textNO
N19:P19Expression=$M$19="X"textNO
N18:P18Expression=$M$18="X"textNO
N17:P17Expression=$M$17="X"textNO
N16:P16Expression=$M$16="X"textNO
N15:P15Expression=$M$15="X"textNO
J22:L22Expression=$I$22="X"textNO
J21:L21Expression=$I$21="X"textNO
J20:L20Expression=$I$20="X"textNO
J19:L19Expression=$I$19="X"textNO
J18:L18Expression=$I$18="X"textNO
J17:L17Expression=$I$17="X"textNO
J16:L16Expression=$I$16="X"textNO
J15:L15Expression=$I$15="X"textNO
F22:H22Expression=$E$22="X"textNO
F21:H21Expression=$E$21="X"textNO
F20:H20Expression=$E$20="X"textNO
F19:H19Expression=$E$19="X"textNO
F18:H18Expression=$E$18="X"textNO
F17:H17Expression=$E$17="X"textNO
F16:H16Expression=$E$16="X"textNO
F15:H15Expression=$E$15="X"textNO
B22:D22Expression=$A$22="X"textNO
B21:D21Expression=$A$21="X"textNO
B20:D20Expression=$A$20="X"textNO
B19:D19Expression=$A$19="X"textNO
B18:D18Expression=$A$18="X"textNO
B17:D17Expression=$A$17="X"textNO
B16:D16Expression=$A$16="X"textNO
B15:D15Expression=$A$15="X"textNO
A15:A22,M15:M22,Q15:Q22,U15:U22,Y15:Y22,Y25:Y32,U25:U32,Q25:Q32,M25:M32,I25:I32,E25:E32,A25:A32,A35:A42,E35:E42,I35:I42,M35:M42,Q35:Q42,U35:U42,Y35:Y42,Y45:Y52,U45:U52,Q45:Q52,M45:M52,I45:I52,E45:E52,A45:A52,A55:A62,E55:E62,I55:I62,M55:M62,Q55:Q62,U55:U62Cell Valuecontains ""textNO
A13,E13,I13,M13,Q13,U13,Y13,A23,E23,I23,M23,Q23,U23,Y23,Y33,U33,Q33,M33,I33,E33,A33,A43,E43,I43,M43,Q43,U43,Y43,Y53,U53,Q53,M53,I53,E53,A53,A63,E63,I63,M63,Q63,U63,Y63Expression=MONTH(A13)<>MONTH($AI$11)textNO
D15:D22,D25:D32,H15:H22,L15:L22,P15:P22,T15:T22,X15:X22,AB15:AB22,H25:H32,L25:L32,L35:L42,L45:L52,H35:H42,D35:D42,H45:H52,D45:D53,D43,D33,D23,H23,D13,H13,L13,P13,T13,X13,AB13,AB23,X23,T23,P23,L23,H33,L33,P33,P25:P32,T25:T33,X25:X33,AB25:AB33,AB35:AB43Cell Value<0textNO

Budget Calendar2.0.1.xlsm
BCD
76DateBillsAmount
772/1/2022Mortgage$1,350.00
782/1/2022Bosco$146.00
792/1/2022Water$40.00
802/3/2022Chase$30.00
812/3/2022Capital One$30.00
822/3/2022Capital One$30.00
832/3/2022Amazon$30.00
Sheet1
Cell Formulas
RangeFormula
B77:B79B77=DATEVALUE($A$10)
B80:B83B80=DATEVALUE($A$10)+2
Named Ranges
NameRefers ToCells
Print_Area=Sheet1!$A$10:$AB$72B77:B83
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
To be fair I don't think I asked a question. I have tried to write several code attempts and I have failed.
This is one of the codes I attempted but it only turned the cell to true, Plus it was the cell that had the
date and I don't want to change the date values at all. I want to input the data from sheet 2 into a cell two rows down
then go to the next item on sheet 2 and so on until all dates have been put into the correct cells. Again any help is greatly appreciated.
So my question is How do I match dates and not change the date value to true? and how do I copy the data into right cells on the calendar?

Sub Add_Bills()

Dim MyRange As Range
Dim MyRange1 As Range
Dim MyRange2 As Range
Dim MyRange3 As Range
Dim MyRange4 As Range
Dim MyRange5 As Range
Dim MyCell As Range

Set MyRange = Sheets("Sheet1").Range("A13:Y13")
Set MyRange1 = Sheets("Sheet1").Range("A23:Y23")
Set MyRange2 = Sheets("Sheet1").Range("A33:Y33")
Set MyRange3 = Sheets("Sheet1").Range("A43:Y43")
Set MyRange4 = Sheets("Sheet1").Range("A53:Y53")
Set MyRange5 = Sheets("Sheet1").Range("A63:Y63")

For Each MyCell In MyRange

If MyCell.Value = Sheets("Sheet2").Range("A2").Value Then
MyCell.Value = Sheets("Sheet2").Range("B3").Copy

Sheets("Sheet1").Range("myRange").Offset(1, 4).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
 
Upvote 0
Well this is the code I wrote and it seems to work. I am sure there is a better way to write it, but since no one has commented on it I guess there isn't. Thanks for the help.
Sub Add_Bills()

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A3").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B3").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C3").Value

End If


Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A4").Value Then
myCell.Offset(5, 1).Value = Sheets("Sheet2").Range("B4").Value
myCell.Offset(5, 2).Value = Sheets("Sheet2").Range("C4").Value

End If


Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 3rd
If myCell.Value = Sheets("Sheet2").Range("A5").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B5").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C5").Value

End If


Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A6").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B6").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C6").Value

End If


Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A7").Value Then
myCell.Offset(5, 1).Value = Sheets("Sheet2").Range("B7").Value
myCell.Offset(5, 2).Value = Sheets("Sheet2").Range("C7").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A8").Value Then
myCell.Offset(6, 1).Value = Sheets("Sheet2").Range("B8").Value
myCell.Offset(6, 2).Value = Sheets("Sheet2").Range("C8").Value

End If

Next myCell


For Each myCell In myRange
'Next Day of Month Bills to insert 4th
If myCell.Value = Sheets("Sheet2").Range("A9").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B9").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C9").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A10").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B10").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C10").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A11").Value Then
myCell.Offset(5, 1).Value = Sheets("Sheet2").Range("B11").Value
myCell.Offset(5, 2).Value = Sheets("Sheet2").Range("C11").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 7th
If myCell.Value = Sheets("Sheet2").Range("A12").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B12").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C12").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 10th
If myCell.Value = Sheets("Sheet2").Range("A13").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B13").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C13").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A14").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B14").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C14").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 11th
If myCell.Value = Sheets("Sheet2").Range("A15").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B15").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C15").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 14th
If myCell.Value = Sheets("Sheet2").Range("A16").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B16").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C16").Value

End If

Next myCell
For Each myCell In myRange
'Next Day of Month Bills to insert 15th
If myCell.Value = Sheets("Sheet2").Range("A17").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B17").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C17").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 19th
If myCell.Value = Sheets("Sheet2").Range("A18").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B18").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C18").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 21st
If myCell.Value = Sheets("Sheet2").Range("A19").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B19").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C19").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A20").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B20").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C20").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A21").Value Then
myCell.Offset(5, 1).Value = Sheets("Sheet2").Range("B21").Value
myCell.Offset(5, 2).Value = Sheets("Sheet2").Range("C21").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 22nd
If myCell.Value = Sheets("Sheet2").Range("A22").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B22").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C22").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 25th
If myCell.Value = Sheets("Sheet2").Range("A23").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B23").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C23").Value

End If

Next myCell

For Each myCell In myRange

If myCell.Value = Sheets("Sheet2").Range("A24").Value Then
myCell.Offset(4, 1).Value = Sheets("Sheet2").Range("B24").Value
myCell.Offset(4, 2).Value = Sheets("Sheet2").Range("C24").Value

End If

Next myCell

For Each myCell In myRange
'Next Day of Month Bills to insert 28th
If myCell.Value = Sheets("Sheet2").Range("A25").Value Then
myCell.Offset(3, 1).Value = Sheets("Sheet2").Range("B25").Value
myCell.Offset(3, 2).Value = Sheets("Sheet2").Range("C25").Value

End If

Next myCell

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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