+ Reply to Thread
Results 1 to 8 of 8

Fine tuning a macro...

Hybrid View

  1. #1
    Registered User
    Join Date
    01-04-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    67

    Fine tuning a macro...

    Hello,

    Using this website and my knowledge i have made the following Macro:
    Sub Button_Click()
    Range("D15").Value = "COMPLETED"
    Range("H43").Value = Date
    Range("C16").Formula = "=Delivery!$C$16"
    Sheets(Array("Delivery")).PrintOut Copies:=1
    End Sub
    However I want this to run when Cell E5 is clicked on.
    Also the date is currently displayed as 30/07/2013.
    I would like the date to display 30.07.13 - is there any way to change this?

    Thanks
    Darren

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Fine tuning a macro...

    Try this, which goes in the worksheet module.
    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Address(0, 0) = "D5" Then
            Range("D15").Value = "COMPLETED"
            
            With Range("H43")
                .NumberFormat = "dd.mm.yyyy"
                .Value = Date
            End With
    
            Range("C16").Formula = "=Delivery!$C$16"
            Sheets(Array("Delivery")).PrintOut Copies:=1
        End If
    
    End Sub
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-04-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    67

    Re: Fine tuning a macro...

    Does this code you sent include the e5 cell part?

    Thanks

  4. #4
    Registered User
    Join Date
    01-04-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    67

    Re: Fine tuning a macro...

    Sorry this doesnt seem to be working? Do i need to add any other code to this?

    Thanks
    Darren

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Fine tuning a macro...

    Darren

    Where exactly did you put the code?

  6. #6
    Registered User
    Join Date
    01-04-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    67

    Re: Fine tuning a macro...

    I created a macro and copy and pasted the code in exactly how it was above - is that wrong?

    Thanks
    Darren

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Fine tuning a macro...

    Darren

    Yes, but so's my code.

    I thought it was D5 not E5.

    Here's the amended code.
    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Address(0, 0) = "E5" Then
            Range("D15").Value = "COMPLETED"
            
            With Range("H43")
                .NumberFormat = "dd.mm.yyyy"
                .Value = Date
            End With
    
            Range("C16").Formula = "=Delivery!$C$16"
            Sheets(Array("Delivery")).PrintOut Copies:=1
        End If
    
    End Sub
    To use this code right click the tab of the worksheet where you want to click E5 and select View Code.

    You should now see the worksheet's module.

    Paste the code in there and close VBE (ALT+Q) to return to Excel.

    Now when you click on E5 the code should run.

  8. #8
    Registered User
    Join Date
    01-04-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    67

    Re: Fine tuning a macro...

    That's great - thank you so much works perfectly!

+ 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. [SOLVED] Need help fine tuning a macro
    By jaimeteele in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-27-2013, 04:43 PM
  2. [SOLVED] need help fine tuning a formula
    By nje in forum Excel General
    Replies: 4
    Last Post: 07-10-2012, 04:55 AM
  3. Great macro for filtering a unique list - some fine tuning
    By pekde in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2010, 01:32 AM
  4. Fine-tuning VBA code
    By smurray444 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2007, 11:49 AM
  5. [SOLVED] help w/ fine tuning
    By Mike in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-19-2005, 04:05 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