Results 1 to 12 of 12

How to: free text cell, that can also assume a value depending on other cell?

Threaded View

EmmaLearns How to: free text cell, that... 12-08-2024, 02:29 PM
TMS Re: How to: free text cell,... 12-08-2024, 03:28 PM
EmmaLearns Re: How to: free text cell,... 12-08-2024, 03:35 PM
TMS Re: How to: free text cell,... 12-08-2024, 04:00 PM
EmmaLearns Re: How to: free text cell,... 12-08-2024, 04:25 PM
TMS Re: How to: free text cell,... 12-08-2024, 07:34 PM
TMS Re: How to: free text cell,... 12-08-2024, 07:46 PM
EmmaLearns Re: How to: free text cell,... 12-12-2024, 11:17 AM
TMS Re: How to: free text cell,... 12-12-2024, 12:49 PM
EmmaLearns Re: How to: free text cell,... 12-12-2024, 05:16 PM
TMS Re: How to: free text cell,... 12-12-2024, 05:25 PM
TMS Re: How to: free text cell,... 12-12-2024, 06:09 PM
  1. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,196

    Re: How to: free text cell, that can also assume a value depending on other cell?

    In the workbook, you mention cell C9. However, that is not affected by the drop down selection. I think you mean cell G9, and that is what the code updates.

    Right click on the Calculations tab
    Select "View Code"
    In the Main code pane, paste the following code:

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    ' Define and set the "range of interest" = cell E9
    Dim rInterest As Range
    Set rInterest = Me.Range("E9")
    
    ' Check if the Target cell is the range of interest
    If Intersect(Target, rInterest) Is Nothing Then Exit Sub
    ' Check if multiple cells have changed (say, if clearing several cells)
    If Target.Cells.CountLarge > 1 Then Exit Sub
    
    Application.EnableEvents = False    ' Stop Event handling
    On Error Resume Next                ' Continue if any error(s)
    
    If Target.Value = "" Then
        ' Clear the cell if the Target is empty
        Target.Offset(, 2).Value = ""
    Else
        ' Drop the formula into the cell
        With Target.Offset(, 2)
            .Formula = _
                "=IFERROR(VLOOKUP(" & Target.Address & ",Data!B77:D87,3,FALSE),"""")"
            .Value = .Value
        End With ' Target.Offset(, 2)
    End If ' Target.Value = ""
    
    On Error GoTo 0                 ' Clear Error handling
    Application.EnableEvents = True ' Resume Event handling
    
    End Sub
    Please note that you will need to save your workbook as macro enabled (.xlsm or .xlsb). And you will need to enable macros when you open the workbook.

    Please see the attached updated sample workbook.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 01-20-2022, 10:21 AM
  2. Drop-Down List OR Free Text Dependent On Another Cell's Value
    By STBTC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-02-2022, 09:33 AM
  3. Formula to add free text to a cell on a continuoual basis
    By sekhar_gs in forum Excel General
    Replies: 3
    Last Post: 10-02-2017, 08:52 AM
  4. [SOLVED] Find Multiple keywords from free text cell
    By amitmodi_mrt in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-31-2017, 02:58 AM
  5. how to make a particular cell assume the name of the worksheet
    By kelsnjoku in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-05-2014, 05:17 AM
  6. [SOLVED] Looking for formula to extract state names from free text cell... HELP!
    By howardulson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-22-2014, 04:46 PM
  7. [SOLVED] Stopping free text entry in validation cell
    By smf in forum Excel General
    Replies: 2
    Last Post: 12-15-2005, 03:50 PM

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