+ Reply to Thread
Results 1 to 6 of 6

Excel Macro That Changes Things when the date is changed?

Hybrid View

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Lusaka, Zambia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Unhappy Excel Macro That Changes Things when the date is changed?

    Good day,

    I have a bit of a problem. I have two worksheets. The first has two cells:
    Book_1.png

    I would like the Certificate No to change every time the date is changed. i.e if the user changes the month value from Mar-13 to Apr-13, i would like the certificate number to increase by 1. The certificate does not have the same value as the month. It could be any number.

    The date also changes the columns in another sheet
    Workbook_2.png

    i.e all the values from the "Total to Date" column move to the column labeled "Previous". I am not an excel user and my employer wants me to do this. . Any help will be appreciated.

    Thanks in advance.
    Last edited by frahmed99; 04-25-2013 at 08:25 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel Macro That Changes Things when the date is changed?

    For your first problem maybe:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B35")) Is Nothing Then
        Target.Offset(2).Value = Target.Offset(2).Value + 1
    End If
    End Sub

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    Lusaka, Zambia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Excel Macro That Changes Things when the date is changed?

    Thank You. That has helped me out. But I am still stuck with the second part. Can someone please help me

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel Macro That Changes Things when the date is changed?

    Not sure I understand your layout on the second part, but see if this helps.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B35")) Is Nothing Then
        Target.Offset(2).Value = Target.Offset(2).Value + 1
        Sheets("Workbook2").Range("E12:E14").Cut Sheets("Workbook2").Range("C12:C14")
    End If
    
    End Sub

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Lusaka, Zambia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Excel Macro That Changes Things when the date is changed?

    OMG. That is brilliant. Thank You very much. I was using the Select command:
    Sheets ("Workbook2").Select
    Range("E12:E14").Select
    Selection.Cut
    Range("C3:C27").Select
    ActiveSheet.Paste
    LOL. And it obviously didnt work. Thank you very much. You dont know how much you have helped me.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel Macro That Changes Things when the date is changed?

    You're welcome. Glad to hear that it works for you. Thank you for the feedback, please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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