Solved Need To Create A Macro!

BomberAF

New member
Member
VIP
Local time
7:29 AM
Messages
491
Location
Liverpool
I currently have a spreadsheet that I use to record monthly payments, so that I can see how much my new balance is and how many more payments I have left. There are several different items over several rows in the table on the spreadsheet, so when I have made a payment I have to work out each individual item and then change the corresponding column. All the items are at different levels of being paid off and they all have different monthly amounts that need to be paid off, so it can take a while and get quite repetitive. Is there a way that I can record a macro that will allow me to just press a button and the amounts are all reduced and then shown in the correct column automatically?
 

My Computer

Computer Manufacturer/Model Number
Dell Inspiron
OS
Windows 7
CPU
2.4 GHz Intel i3 cpu
Memory
8GB
Mouse
MS Explorer Mouse
Internet Speed
100 Mb/s

My Computer

OS
windows7
Please dont post shortened urls on the forum, it makes it much harder to spot malicious links.
 

My Computer

Computer type
PC/Desktop
OS
Windows 11
I currently have a spreadsheet that I use to record monthly payments, so that I can see how much my new balance is and how many more payments I have left. There are several different items over several rows in the table on the spreadsheet, so when I have made a payment I have to work out each individual item and then change the corresponding column. All the items are at different levels of being paid off and they all have different monthly amounts that need to be paid off, so it can take a while and get quite repetitive. Is there a way that I can record a macro that will allow me to just press a button and the amounts are all reduced and then shown in the correct column automatically?
Can you post an example of what you are trying to do?

Are the payments the same every month? Are they paid on the same day? If so, it would be fairly trivial to write a macro that would allow you to press a button that would automatically decrement each column by the set monthly payment. Things get a little more involved if the payment is different each month and/or the various payments are made on different days.

If any of these things that are being paid down involve interest, that's another level of complexity.

(I'm extremely jealous of your internet DL speed!)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Built desktop, Dell G15 5511 Gaming laptop,MS Surface Pro 7 tablet
OS
W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
CPU
3.7Ghz 8700K i7, i7-11800H, i7-1065G7
Motherboard
ASUS TUF Z370-Pro Gaming in desktop
Memory
16G desktop, 16G laptop, 4G tablet
Graphics Card(s)
AMD Radeon RX580, RTX 3060, Intel Iris Plus
Sound Card
High Definition Audio (Built-in to mobo)
Monitor(s) Displays
Samsung U32J59 32" (2x), 15.6", 12"
Screen Resolution
3840x2160, 3840x2160, 1920x1080, 2160x1440
Hard Drives
500G SSD for OS; 2T, 10T & 15T HDDs for Data on Desktop, 1TB SSD laptop, 128G SSD tablet.
PSU
Corsair CX 750M
Case
Antec 100
Cooling
CM 212+
Keyboard
IBM Model M - used continuously since 1986
Mouse
Microsoft Pro IntelliMouse
Internet Speed
400M down 8M up
Antivirus
Windows Defender
Browser
FireFox
Other Info
Built my first computer (8Mhz 8088cpu, 640K RAM, 20MB HDD, 2 360K floppy drives) in 1985 and have been building them for myself, relatives and friends ever since.
I currently have a spreadsheet that I use to record monthly payments, so that I can see how much my new balance is and how many more payments I have left. There are several different items over several rows in the table on the spreadsheet, so when I have made a payment I have to work out each individual item and then change the corresponding column. All the items are at different levels of being paid off and they all have different monthly amounts that need to be paid off, so it can take a while and get quite repetitive. Is there a way that I can record a macro that will allow me to just press a button and the amounts are all reduced and then shown in the correct column automatically?
Can you post an example of what you are trying to do?

Are the payments the same every month? Are they paid on the same day? If so, it would be fairly trivial to write a macro that would allow you to press a button that would automatically decrement each column by the set monthly payment. Things get a little more involved if the payment is different each month and/or the various payments are made on different days.

If any of these things that are being paid down involve interest, that's another level of complexity.

(I'm extremely jealous of your internet DL speed!)


Thanks for the reply, here is the table that I want to create a macro for:

axh92a.png


As you can see there are a number of different payment that all take place on the same day. The payments don't change each month but each item has a different payment.



I am happy with my download speed but my upload is only at 5mbs but shall go to 10 by the end of the year once Virgin Media have finished boosting everyone's speed. I also find it strange the being in California the richest state in the richest country in the world you don't seem to have very fast broadband.
 
Last edited:

My Computer

Computer Manufacturer/Model Number
Dell Inspiron
OS
Windows 7
CPU
2.4 GHz Intel i3 cpu
Memory
8GB
Mouse
MS Explorer Mouse
Internet Speed
100 Mb/s
Here's a quick and dirty macro that will do what you want:

Code:
Sub pay_bills()

For x = 4 To 10
   If Worksheets(1).Cells(x, 5) >= 0 Then
      Worksheets(1).Cells(x, 5).Value = (Worksheets(1).Cells(x, 5).Value - Worksheets(1).Cells(x, 4).Value)
      If Worksheets(1).Cells(x, 5) <= 0 Then
         Worksheets(1).Cells(x, 4).Value = 0
      End If
   End If
   
Next

End Sub

You can go into the Visual Basic Editor and Add a module to the first worksheet then copy this code into it and save it. You can then assign a key combo (such as Ctrl-p) to run the macro. After that, every month when you pay your bills just press your assigned key combo to update the values.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Built desktop, Dell G15 5511 Gaming laptop,MS Surface Pro 7 tablet
OS
W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
CPU
3.7Ghz 8700K i7, i7-11800H, i7-1065G7
Motherboard
ASUS TUF Z370-Pro Gaming in desktop
Memory
16G desktop, 16G laptop, 4G tablet
Graphics Card(s)
AMD Radeon RX580, RTX 3060, Intel Iris Plus
Sound Card
High Definition Audio (Built-in to mobo)
Monitor(s) Displays
Samsung U32J59 32" (2x), 15.6", 12"
Screen Resolution
3840x2160, 3840x2160, 1920x1080, 2160x1440
Hard Drives
500G SSD for OS; 2T, 10T & 15T HDDs for Data on Desktop, 1TB SSD laptop, 128G SSD tablet.
PSU
Corsair CX 750M
Case
Antec 100
Cooling
CM 212+
Keyboard
IBM Model M - used continuously since 1986
Mouse
Microsoft Pro IntelliMouse
Internet Speed
400M down 8M up
Antivirus
Windows Defender
Browser
FireFox
Other Info
Built my first computer (8Mhz 8088cpu, 640K RAM, 20MB HDD, 2 360K floppy drives) in 1985 and have been building them for myself, relatives and friends ever since.
Here's a quick and dirty macro that will do what you want:

Code:
Sub pay_bills()

For x = 4 To 10
   If Worksheets(1).Cells(x, 5) >= 0 Then
      Worksheets(1).Cells(x, 5).Value = (Worksheets(1).Cells(x, 5).Value - Worksheets(1).Cells(x, 4).Value)
      If Worksheets(1).Cells(x, 5) <= 0 Then
         Worksheets(1).Cells(x, 4).Value = 0
      End If
   End If
   
Next

End Sub

You can go into the Visual Basic Editor and Add a module to the first worksheet then copy this code into it and save it. You can then assign a key combo (such as Ctrl-p) to run the macro. After that, every month when you pay your bills just press your assigned key combo to update the values.

Thanks for that, I am just about to have my dinner, so when I have finished I will give that a bash.

Cheers :D
 

My Computer

Computer Manufacturer/Model Number
Dell Inspiron
OS
Windows 7
CPU
2.4 GHz Intel i3 cpu
Memory
8GB
Mouse
MS Explorer Mouse
Internet Speed
100 Mb/s
Can you confirm some points for me please.

So the Sub pay_bils(), is the name of the macro you are about to create.

The spreadsheet is on worksheet 3 so I can just use worksheet 3 instead of the name I have used on the spreadsheet.

I don't understand the command 'If Worksheets(1).Cells(x, 5) >= 0 Then'. Do I have to replace x with the corresponding column.

I also don't understand where you get the number 5 from, so can you please explain this a bit more for me if you don't mind.

Sorry for being a pain, but your help is greatly appreciated.
 

My Computer

Computer Manufacturer/Model Number
Dell Inspiron
OS
Windows 7
CPU
2.4 GHz Intel i3 cpu
Memory
8GB
Mouse
MS Explorer Mouse
Internet Speed
100 Mb/s
Got this sorted now, working a treat!

Got it working with the help if this gem of a forum http://www.excelforum.com/ I am sure the MODS wont mind this link being posted as it is a great site for EXCEL problems.

Many thanks all I got the solution from this forum but many thanks to all who helped.
 

My Computer

Computer Manufacturer/Model Number
Dell Inspiron
OS
Windows 7
CPU
2.4 GHz Intel i3 cpu
Memory
8GB
Mouse
MS Explorer Mouse
Internet Speed
100 Mb/s
Hi BomberAF,
Glad to hear that you got it working,

Regards,
Rajeev
Dell | Social Media and Outreach|
 

My Computer

OS
windows7
Back
Top