+ Reply to Thread
Results 1 to 6 of 6

Previous Month / Next Month Incremental Button

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-03-2016
    Location
    Sydney, Australia
    MS-Off Ver
    MS 365
    Posts
    128

    Previous Month / Next Month Incremental Button

    Hi there,

    I've created a spreadsheet containing data for a few years.

    I want to insert two buttons, one for "Previous Month" and one for "Next Month".

    I basically want them to work like how the 'spin button' works but instead of the arrows that appear on the 'spin button', I want the above words to show, hence using commandbuttons.

    I need the two buttons to be linked to cell $e$30, when the "Previous Month" button is clicked, I want the number to decrease on each click until you get to 0 and when the "Next Month" button is clicked, I want the number to increase on each click.

    Is this possible to do and if so, are you able to provide me with the macro?

    Thanks

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,719

    Re: Previous Month / Next Month Incremental Button

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    10-03-2016
    Location
    Sydney, Australia
    MS-Off Ver
    MS 365
    Posts
    128

    Re: Previous Month / Next Month Incremental Button

    Hi,

    Seems pretty basic, I've attached a excel spreadsheet of what I'd like to do.

    The top area highlighted in orange is a spin-button. The spin button is linked to cell $E$4. When you click on the up arrow, the linked cell will increase from the value 0. When you click on the down arrow, the value will decrease until you get to 0.

    I want this same method to be implemented on a commandbutton instead (purely as I want there to be a word instead of the arrow).

    CommandButton1 is titled "Previous Month", I want this to do what the down button on the spin-button does.
    CommandButton2 is titled "Next Month", I want this to do what the up button on the spin-button does.
    I would like both commandbuttons linked to cell $E$13, so no matter what button you click, the resulting number changes in the same cell.
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Previous Month / Next Month Incremental Button

    Hi Anarchus

    Try this...
    Option Explicit
    
    Private Sub CommandButton1_Click()
       If Cells(13, "E").Value >= 1 Then
          Cells(13, "E").Value = Cells(13, "E").Value - 1
       End If
    End Sub
    
    Private Sub CommandButton2_Click()
       Cells(13, "E").Value = Cells(13, "E").Value + 1
    End Sub
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Contributor
    Join Date
    10-03-2016
    Location
    Sydney, Australia
    MS-Off Ver
    MS 365
    Posts
    128

    Re: Previous Month / Next Month Incremental Button

    Thank you so much, that's exactly what I wanted!

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Previous Month / Next Month Incremental Button

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code adjustment to include only current month and previous month automatically.
    By ElmerFud in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-05-2015, 03:02 PM
  2. Replies: 1
    Last Post: 07-06-2015, 04:43 PM
  3. Macro using vlookups comparing 2 months paysheet(previous month and current month)
    By srinivasan1965 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-07-2012, 03:45 AM
  4. Replies: 5
    Last Post: 10-04-2012, 07:06 AM
  5. [SOLVED] VBA to identify the current month and previous month based on system date
    By ravikumar00008 in forum Excel General
    Replies: 10
    Last Post: 07-26-2012, 10:04 AM
  6. Replies: 4
    Last Post: 03-19-2012, 08:58 AM
  7. [SOLVED] copy worksheet from previous month and rename to current month
    By Dan E. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2005, 05:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1