+ Reply to Thread
Results 1 to 9 of 9

[SOLVED]Change Macro to enter full amount

Hybrid View

  1. #1
    Registered User
    Join Date
    03-20-2008
    Posts
    30

    [SOLVED]Change Macro to enter full amount

    Evening all

    I know nothing about macro's and the person that created the macro on this sheet is not here. Can anyone change it for me/advise what to do?

    At the minute we press ctrl+E (on cell C5 on Sunday page) and enter 2 rounded up figures in the pop up boxes (i.e 32, then 2, the 2nd amount is deducted from the first) what we want to do is enter 2 full figures (i.e 31599 and 2499) and then have the macro round the figure to the nearest thousand.

    Is this possible?

    Sal
    Attached Files Attached Files
    Last edited by auntsally; 03-20-2010 at 07:15 AM. Reason: Sorted

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Change Macro to enter full amount

    Replace the code that's there with this:
    Sub DualEnv()
        ' Keyboard Shortcut: CTRL + E
    
        Dim iRow        As Long
        Dim iCol        As Long
        Dim sInp        As String
        Dim nVal        As Long
        Dim iRetail     As Long
        Dim iNonTrd     As Long
        Dim sPfx        As String
    
        iRow = ActiveCell.Row
        iCol = ActiveCell.Column
    
        sInp = InputBox("Enter Retail-J total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iRetail = CLng(sInp)
            nVal = nVal + 1
        End If
    
        sInp = InputBox("Enter Retail-J non-trade total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iNonTrd = CLng(sInp)
            nVal = nVal + 1
        End If
    
        If nVal < 2 Then
            MsgBox "Please enter valid currency amounts."
        
        Else
            Select Case Cells(iRow, "A").Value
                Case "L'don":  sPfx = "London = "
                Case "T'ford": sPfx = "Trafford = "
                Case "Exch":   sPfx = "Exchange = "
                Case "B'ham":  sPfx = "Birmingham = "
                Case "Ecom":   sPfx = "Ecommerce = "
                Case Else:     sPfx = ""
            End Select
    
            ActiveCell.Value = sPfx & Format(iRetail - iNonTrd, "0,") & "k"
        End If
    End Sub
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-20-2008
    Posts
    30

    Re: Change Macro to enter full amount

    Thanks for that.

    I've changed the code but the only thing thats not working is the actual CTRL + E part of it. We can do ALT+F8 then run the macro and it works fine, but CTRL + E doesn't do anything.

    I've checked security settings and made sure I clicked enable macros when opening the sheet. I've also tried changing the key combination. Any idea what might be stopping it?.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change Macro to enter full amount

    Don't replace the whole sub. Open the original workbook, Alt+F11 to open the VB Editor.Then paste Shg's code below over the existing code after
    Sub DualEnv()
    '
    ' DualEnv Macro
    ' David Piggin - Selfridges Retail Ltd
    '
    ' Keyboard Shortcut: CTRL + E
    '
      Dim iRow        As Long
        Dim iCol        As Long
        Dim sInp        As String
        Dim nVal        As Long
        Dim iRetail     As Long
        Dim iNonTrd     As Long
        Dim sPfx        As String
    
        iRow = ActiveCell.Row
        iCol = ActiveCell.Column
    
        sInp = InputBox("Enter Retail-J total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iRetail = CLng(sInp)
            nVal = nVal + 1
        End If
    
        sInp = InputBox("Enter Retail-J non-trade total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iNonTrd = CLng(sInp)
            nVal = nVal + 1
        End If
    
        If nVal < 2 Then
            MsgBox "Please enter valid currency amounts."
        
        Else
            Select Case Cells(iRow, "A").Value
                Case "L'don":  sPfx = "London = "
                Case "T'ford": sPfx = "Trafford = "
                Case "Exch":   sPfx = "Exchange = "
                Case "B'ham":  sPfx = "Birmingham = "
                Case "Ecom":   sPfx = "Ecommerce = "
                Case Else:     sPfx = ""
            End Select
    
            ActiveCell.Value = sPfx & Format(iRetail - iNonTrd, "0,") & "k"
        End If
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    03-20-2008
    Posts
    30

    Re: Change Macro to enter full amount

    Thanks for the reply

    Ok, so now i've got the code as shown below but still nothing happens when I do CTRL E.

    Sub DualEnv()
    '
    ' DualEnv Macro
    ' David Piggin - Selfridges Retail Ltd
    '
    ' Keyboard Shortcut: CTRL + E
    '
    
        Dim iRow        As Long
        Dim iCol        As Long
        Dim sInp        As String
        Dim nVal        As Long
        Dim iRetail     As Long
        Dim iNonTrd     As Long
        Dim sPfx        As String
    
        iRow = ActiveCell.Row
        iCol = ActiveCell.Column
    
        sInp = InputBox("Enter Retail-J total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iRetail = CLng(sInp)
            nVal = nVal + 1
        End If
    
        sInp = InputBox("Enter Retail-J non-trade total for Store", "Hourly Sales", 0)
        If Len(sInp) And IsNumeric(sInp) Then
            iNonTrd = CLng(sInp)
            nVal = nVal + 1
        End If
    
        If nVal < 2 Then
            MsgBox "Please enter valid currency amounts."
        
        Else
            Select Case Cells(iRow, "A").Value
                Case "L'don":  sPfx = "London = "
                Case "T'ford": sPfx = "Trafford = "
                Case "Exch":   sPfx = "Exchange = "
                Case "B'ham":  sPfx = "Birmingham = "
                Case "Ecom":   sPfx = "Ecommerce = "
                Case Else:     sPfx = ""
            End Select
    
            ActiveCell.Value = sPfx & Format(iRetail - iNonTrd, "0,") & "k"
        End If
    End Sub

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Change Macro to enter full amount

    works for me but you have to reassign ctrl+e in tools/macro/macros/options
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Registered User
    Join Date
    03-20-2008
    Posts
    30

    Re: Change Macro to enter full amount

    Ah, thats the problem. It's on CTRL+SHIFT - I cant remove the SHIFT part of it.

  8. #8
    Registered User
    Join Date
    03-20-2008
    Posts
    30

    Re: Change Macro to enter full amount

    NVM, stupid caps lock! Just realised thats why it wants the shift key.

    Thanks for all your help

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change Macro to enter full amount

    The shortcut worked for me just pasting the body of the code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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