+ Reply to Thread
Results 1 to 5 of 5

Cell that allows both formula and manual input options

Hybrid View

  1. #1
    Registered User
    Join Date
    05-12-2016
    Location
    San Jose
    MS-Off Ver
    2010
    Posts
    22

    Cell that allows both formula and manual input options

    Hello,

    In the attached file, I have a drop-down menu (cell A3) that allows users to determine whether they want to manually input a number in a specific cell (cell F3) or have the worksheet input a placeholder value for them in that cell. The problem is that anytime a user manually inputs a number in F3, it overwrites the formula that pulls in the placeholder value from the second tab (cell B2). Thus, if the user switches back to "placeholder value" option, cell F3 no longer works properly.

    I know I can work around this by creating additional rows and using if/then statement, but really hoping to maintain the format of having just one cell for both the input and placeholder value. I believe this requires VBA. Can anyone help me accomplish this? *Thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Cell that allows both formula and manual input options

    Hi,

    You can do it using a macro like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Target.Address = "$A$3" Then Exit Sub
        If Target = "Use Placeholder" Then
            Range("D3").Formula = "='Literature-Based Inputs'!B2"
            Range("C3") = "Placeholder: "
        ElseIf Target = "Input Actual" Then
            Range("D3").ClearContents
            Range("C3") = "Input: "
        End If
    End Sub
    Attached Files Attached Files
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Registered User
    Join Date
    05-12-2016
    Location
    San Jose
    MS-Off Ver
    2010
    Posts
    22

    Re: Cell that allows both formula and manual input options

    Thank you Stephen,

    That definitely worked. However, on my actual spreadsheet i have 4 different drop-downs that i need to do the same thing for, yet VBA won't let me duplicate this code 4 times in one worksheet.
    For example, for 1 of the 4 drop-downs might be an input, while the other 3 pull from the 2nd tab.
    Is there a way to do this? See attached file and thanks again!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Cell that allows both formula and manual input options

    You could do it several ways.
    Maybe like this?

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Count > 1 Then Exit Sub
        If Target = "Use Placeholder" Then
            Target.Offset(0, 2) = "Placeholder: "
            Target.Offset(0, 3) = Sheets(2).Range(Target.Address).Offset(-1, 1)
        ElseIf Target = "Input Actual" Then
            Target.Offset(0, 2) = "Input: "
            Target.Offset(0, 3).ClearContents
        End If
    End Sub

  5. #5
    Registered User
    Join Date
    05-12-2016
    Location
    San Jose
    MS-Off Ver
    2010
    Posts
    22

    Re: Cell that allows both formula and manual input options

    Works perfectly. Much appreciated!

+ 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. Replies: 7
    Last Post: 07-02-2016, 07:26 PM
  2. Option to put in manual input without erasing the formula.
    By shamsul in forum Access Tables & Databases
    Replies: 3
    Last Post: 07-02-2016, 12:35 AM
  3. [SOLVED] Cell equals formula OR manual input
    By PDBartlett in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-20-2014, 05:52 AM
  4. Replies: 1
    Last Post: 02-24-2013, 06:27 PM
  5. [SOLVED] Formula and Manual Input
    By Yidolee in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-18-2013, 01:37 PM
  6. Run Macro on cell change from streaming data (not manual user input)
    By Test123Test in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-20-2012, 12:58 PM
  7. Having a mcro prompt me for manual input in cell
    By Leon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2006, 03:30 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