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!

assign a custom character to a keyboard key in excel

As above really, I produce a large number of spreadsheets into which test results are entered. In locations (cells) where no data is recorded this is indicated by entering a hyphen symbol multiple times.

I wonder is it possible to produce a custom symbol which consists of say 5 hyphens (essentially a dashed line) which could be input by hitting a single keystroke?

I have checked the special characters which are available as standard but none of them seem to be suitable, any help would be appreciated.

Thanks
«1

Comments

  • Andy_L
    Andy_L Posts: 13,083 Forumite
    Part of the Furniture 10,000 Posts Name Dropper
    If its just to indicate that the cell is "intentionally blank" rather than missed out do you need 5 dashes rather than just 1?
    If its needed to draw the eye to missing data you could use conditional formatting to tune the cell red if there is just 1 dash entered
  • rubble2
    rubble2 Posts: 569 Forumite
    Part of the Furniture 100 Posts Name Dropper
    It is to report that the cell is intentionally blank, one dash just looks a bit 'lost'. I have always entered multiple dashes and would prefer to continue doing so, just looking for a quicker way of achieving this.
  • System
    System Posts: 178,375 Community Admin
    10,000 Posts Photogenic Name Dropper
    edited 18 September 2014 at 9:08AM
    Write a macro to put your hyphens in the current cell and assign the macro to a shortcut key
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+q
    '
    ActiveCell.FormulaR1C1 = "'
    "

    End Sub
    How you link to a shortcut key may vary depending on Excel version
    This is a system account and does not represent a real person. To contact the Forum Team email forumteam@moneysavingexpert.com
  • fwor
    fwor Posts: 6,887 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Would it not be far simpler to use the Autocorrect function instead of writing macros?
  • System
    System Posts: 178,375 Community Admin
    10,000 Posts Photogenic Name Dropper
    You could end up hit by the law of unintended consequences.
    This is a system account and does not represent a real person. To contact the Forum Team email forumteam@moneysavingexpert.com
  • indesisiv
    indesisiv Posts: 6,359 Forumite
    Part of the Furniture 1,000 Posts Combo Breaker Debt-free and Proud!
    The length of time it takes you to hit a shortcut will be the same as typing
    Even with using auto correct you are not going to save much time and there may be issues for instance i wouldn't recommend replacing - with
    .
    If there are lots of cells in a row just fill the value down.
    “Time is intended to be spent, not saved” - Alfred Wainwright
  • System
    System Posts: 178,375 Community Admin
    10,000 Posts Photogenic Name Dropper
    But a macro gives guaranteed consistency of content. It's easy enough to only do 4 hyphens by mistake and if there is any counting or manipulation then errors will creep in. A macro removes that area of error.
    This is a system account and does not represent a real person. To contact the Forum Team email forumteam@moneysavingexpert.com
  • paddyrg
    paddyrg Posts: 13,543 Forumite
    http://www.extendoffice.com/documents/excel/772-excel-fill-blank-cells-with-0-or-specific-value.html

    The first of these methods takes a little practice, and read the four steps carefully - but it's powerful and fast

    To open the Go To | Special window, do Control+G, then press the Special button :-)
  • I use a macro very similar to the above to add a tick (windings) in excel, that is assigned to a keyboard shortcut. Save it into my personal.xlsm and the macro is available in every spreadsheet I use.
  • Personally I would just use a Macro for it, however, the drawback of a Macro is that you cannot undo the action. So if you accidentally run it on the wrong cell you could overwrite and lose whatever value was already there. So building on !!!!!!'s code it might be an idea to either publicly store the current ActiveCell value which can then be recalled using an 'undo' Macro should it be required...
    Public undovalue As String

    Sub NoDataValue()
    '
    ' Keyboard Shortcut: Ctrl+Shift+Q
    '
    undovalue = ActiveCell
    ActiveCell.FormulaR1C1 = "'
    "

    End Sub



    Sub NoDataValueUndo()
    '
    ' Keyboard Shortcut: Ctrl+Shift+U
    '
    ActiveCell.FormulaR1C1 = undovalue
    undovalue = Empty

    End Sub
    (I've also amended the shortcut-key combination above as it's a better idea to assign Macros to uppercase letters)

    Or perhaps even easier you could just add an If clause to check if the ActiveCell is blank before entering your value...
    Sub NotIfBlank()
    '
    ' Keyboard Shortcut: Ctrl+Shift+Q
    '
    If ActiveCell <> "" Then Exit Sub Else
    ActiveCell.FormulaR1C1 = "'
    "

    End Sub
    If you find your shortcut-keys are not working, press Alt-F8, then select the Macro and click Options. Then set your preferred shortcut letter (Hold Shift to enter in uppercase) and change to Ctrl+Shift+
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
  • 352.2K Banking & Borrowing
  • 253.6K Reduce Debt & Boost Income
  • 454.3K Spending & Discounts
  • 245.2K Work, Benefits & Business
  • 600.9K Mortgages, Homes & Bills
  • 177.5K Life & Family
  • 259K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K 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.