We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide
Excel : Clickable buttons to copy a value to "current month" field?
Comments
-
I hope the below helps to explain it better
The way I want it to work
- Shopping total to be added up, simple SUM put into cell D15
- Click the button "save to master list", the value from D15 is put into relevant month / year cell
Ignore it being replicated thats because of the formula when I was playing around, in this instance when clicking the button I would want to put the value from D15 in cell K2 (if today was really month end)
EDIT - I know I can manually copy it
However, I'm trying to automate it if possible, because I may be adding in a lot more advanced functions at a later date, since the Excel sheet already has quite a bit of stuff in now

Owner of andrewhope.co.uk, hate cars and love them
Working towards DFD
HSBC Credit Card - £2700 / £7500
AA Loans - (cleared £9700)0 -
Try:
total = ActiveSheet.Range("d15") monthx = Month(Date) yearx = Year(Date) yearmatch = WorksheetFunction.Match(yearx, Range("D:D"), 0) - 1 Range("d1").Select ActiveCell.Offset(yearmatch, monthx).Select ActiveCell.Value = totalIt will take the month and year from todays date and find the corresponding cell and enter D15 in it.0 -
Try:
It will take the month and year from todays date and find the corresponding cell and enter D15 in it.
Thanks for the help Phil
You can use [code] to get rid of smilies
I get an error in the script
"runtime error 1004: range of object_global failed"
When going to VB Debug, it highlights this....
yearmatch = WorksheetFunction.Match(yearx, Range("D : D"), 0) - 1Owner of andrewhope.co.uk, hate cars and love them
Working towards DFD
HSBC Credit Card - £2700 / £7500
AA Loans - (cleared £9700)0 -
Have you taken the spaces out of the range bit? You might also have to make it D1: D12, sometimes you can get away with naming the column, other times it likes an exact range.0
-
Have you taken the spaces out of the range bit? You might also have to make it D1: D12, sometimes you can get away with naming the column, other times it likes an exact range.
thanks ill try it now, i didn't notice there was spaces (because of smilies)
Owner of andrewhope.co.uk, hate cars and love them
Working towards DFD
HSBC Credit Card - £2700 / £7500
AA Loans - (cleared £9700)0 -
Cheers Phil your a star
Was just the range because of the smilies without spaces, removed them and it put the value in the correct month
Thanks
Owner of andrewhope.co.uk, hate cars and love them
Working towards DFD
HSBC Credit Card - £2700 / £7500
AA Loans - (cleared £9700)0
This discussion has been closed.
Confirm your email address to Create Threads and Reply
Categories
- All Categories
- 354.2K Banking & Borrowing
- 254.3K Reduce Debt & Boost Income
- 455.3K Spending & Discounts
- 247.2K Work, Benefits & Business
- 603.8K Mortgages, Homes & Bills
- 178.4K Life & Family
- 261.3K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 37.7K Read-Only Boards