+ Reply to Thread
Results 1 to 7 of 7

If a character is entered, copy formula into cells?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Question If a character is entered, copy formula into cells?

    How can one have a function/formula that when one character is entered into a cell, one formula is copied from two cells (from the same place each time) into the corresponding specified row. And if another character is entered ino the same cell, another formula is copied from two cells (frm the same place each time) into the corresponding specified row?

    Eg.

    If 'Y' is entered - Copy formula from Cell C1 & D1 to C10 & D10
    If 'N' is entered - Copy formula from Cell C2 & D2 to C10 & D10

    When the cell formula is copied it needs to automatically update so if it's copied to C10 it uses that rows data, and if is copied to C11 it uses that rows data.

    Thanks.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a character is entered, copy formula into cells?

    Stoo, if you don't want to embed the formulae, ie:

    C10: =IF(x="Y",formula used in C1,formula used in C2)
    D10: =IF(x="Y",formula used in D1,formula used in D2)

    then you will need to use VBA but you will need to provide more info in terms of where the Y/N is being entered & how (ie manually typed or use of Data Validation, formulae etc...)

  3. #3
    Registered User
    Join Date
    05-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If a character is entered, copy formula into cells?

    DonkeyOte,

    Thanks for your response.

    The 'Y' and the 'N' will be entered manually into a cell.

    Please see attached example.

    Cheers.
    Attached Files Attached Files

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: If a character is entered, copy formula into cells?

    Write this in F6 and G6

    =IF(C6="Y";$F$1;$F$2) =IF(C6="Y";$G$1;$G$2)

    (replac ; with , if needed)

    This will return formula F1 if Y is in C6 or anythign else (can be N but can be any simbol) if not
    Never use Merged Cells in Excel

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a character is entered, copy formula into cells?

    Assuming you want to use VBA - see below (alter Intersect Range to encompass the range you intend to use this with) -- to insert the below right click on "Sheet1" tab and select View Code and paste above into resulting window
    (note you can have only one Worksheet_Change event per sheet object)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Or Intersect(Target, Range("C6:C16")) Is Nothing Then Exit Sub
    With Target.Offset(, 3).Resize(, 2)
        .FormulaR1C1 = .Offset((1 + Abs(UCase(Target.Value) = "N")) - .Row).FormulaR1C1
    End With
    End Sub

  6. #6
    Registered User
    Join Date
    05-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If a character is entered, copy formula into cells?

    My previous sheet was explained slightly wrong. Apologies.

    Please find attached corrected sheet.

    I'd rather stick with functions in cells if possible, makes it easier for me to understand and tweak things if required.

    Thanks for your responses.
    Attached Files Attached Files

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a character is entered, copy formula into cells?

    A formula can not physically copy anything.

    As already outlined, if you want to use formulae you should use construct of:

    =IF(C6="Y",your formula for Y,your formula for N)

    there is no shortcut other than perhaps using a Volatile Named Range which would be ill advised IMO.

+ 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