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?

2»

Comments

  • Lil306
    Lil306 Posts: 1,692 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    edited 3 July 2010 at 4:20PM
    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 :)

    exampleexcel.jpg


    Owner of andrewhope.co.uk, hate cars and love them

    Working towards DFD

    HSBC Credit Card - £2700 / £7500
    AA Loans - (cleared £9700)
  • PhilCo_2
    PhilCo_2 Posts: 136 Forumite
    edited 3 July 2010 at 7:05PM
    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 = total
    
    It will take the month and year from todays date and find the corresponding cell and enter D15 in it.
  • Lil306
    Lil306 Posts: 1,692 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    PhilCo wrote: »
    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) - 1
    Owner of andrewhope.co.uk, hate cars and love them

    Working towards DFD

    HSBC Credit Card - £2700 / £7500
    AA Loans - (cleared £9700)
  • PhilCo_2
    PhilCo_2 Posts: 136 Forumite
    edited 3 July 2010 at 5:34PM
    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.
  • Lil306
    Lil306 Posts: 1,692 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    PhilCo wrote: »
    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)
  • Lil306
    Lil306 Posts: 1,692 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    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)
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

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

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.