+ Reply to Thread
Results 1 to 6 of 6

Display value based off of letter in specific cell.

  1. #1
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Post Display value based off of letter in specific cell.

    I would like to display a certain value in a cell based on two conditions:

    1) If L11 = "P," "K," "C," or "F" then add 0, 1, 2 or 3 accordingly to Column A,

    2) From what's being displayed in column B

    Here is my formula in a VBA Module:
    Function OverStock(L As Range, B As Range)
    If L11 = "P" Then
    OverStock = B
    ElseIf L11 = "K" Then
    OverStock = B + 1
    ElseIf L11 = "C" Then
    OverStock = B + 2
    ElseIf L11 = "F" Then
    OverStock = B + 3
    End If
    End Function

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Display value based off of letter in specific cell.

    Please put your code in
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Re: Display value based off of letter in specific cell.

    how would this then be put into the empty cell where the value needs to be?

    This was my previous formulations to get the desired value:
    =IF(L11="P",B37,IF(L11="K",B37+1,IF(L11="C",B37+2,IF(L11="F",B37+3,""))))
    Going down the list. My problem is when i try to drag the cell value down 30 rows, it changes the L11 value to L12, L13, etc.

    So, I figured, if i'd just create my own variable in VBA, i can avoid this issue.

    Just to give you an idea of my objective.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Display value based off of letter in specific cell.

    Well you can avoid the issue you mentioned by just adding a dollar sign before the 11 in L11. This changes it away from a relative reference.

    Like this: =IF(L$11="P",B37,IF(L$11 etc. etc. etc.

    But let me know if you still want VBA code.

  5. #5
    Registered User
    Join Date
    01-12-2015
    Location
    Seattle, WA, USA
    MS-Off Ver
    2013
    Posts
    19

    Re: Display value based off of letter in specific cell.

    Your a genious, I feel so stupid right now. lol.

    Yes, please also provide me with the vba formatting, I believe by looking at expert coding like yours, i'll be able to gradually improve my own.

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Display value based off of letter in specific cell.

    Here you go. Just adjust the rows you want output on (in my code it's rows 37 through 67).

    Then every time you change the letter in L11, this code will run.

    Please Login or Register  to view this content.
    But personally in this case, i think a formula is a better option.

+ 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. [SOLVED] Display chosen number if cell text begins with specific letter
    By BPSJACK in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2014, 07:12 AM
  2. [SOLVED] Change Color of cell based on specific letter / text
    By steven_e in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2013, 04:46 PM
  3. Display a specific result based on Cell Values in a row (Ex Attached)
    By chadly72 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2013, 03:15 PM
  4. Can name range display value based on the input of specific cell?
    By rusoo7 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-24-2010, 11:17 AM
  5. Replies: 9
    Last Post: 11-16-2009, 07:16 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