1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel formula

Discussion in 'Business Applications' started by soldtheworld, Jul 5, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. soldtheworld

    soldtheworld Thread Starter

    Joined:
    May 29, 2003
    Messages:
    136
    Hi Guys,
    Pls check out the excel sheet attached and let me know if what I want is possible.
    Thanks in advance
     

    Attached Files:

  2. XL Guru

    XL Guru

    Joined:
    Aug 30, 2003
    Messages:
    2,702
    OK (bearing in mind you WILL need to set up the lookup table first).

    You need some code in the worksheet module ; rightclick Sheet1 tab & "View Code" to view it.

    When you enter a valid location # in column C (below row 4) & press Enter, the code will create a VLOOKUP formula one cell to the left & then hard-code it. If you enter a non-valid number you'll get #N/A. If you clear a cell (DEL) in column C (below row 4) the cell to the left will clear.

    The lookup table is on (new) Sheet2. It's dynamically named so that it'll auto-update as rows are added or deleted. Check out the named formula that defines it via Insert -- Name -- Define.

    Rgds,
    Andy
     

    Attached Files:

  3. soldtheworld

    soldtheworld Thread Starter

    Joined:
    May 29, 2003
    Messages:
    136
    Hi Guru,
    (first of all I wanted to thank you for the time you've spent trying to make me understand) :)

    That’s the first time I clicked on “view code”, I never knew how to use this option or even tried to figure out the utility ‘cause it looks complicated to me, Anyway, I did click on view code, then on sheet 2, I get this:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    End Sub

    On sheet1 I get :

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row < 4 Then Exit Sub
    If Target.Column <> 3 Then Exit Sub
    If Target = "" Then
    Target.Offset(0, -1) = ""
    Else
    Target.Offset(0, -1).FormulaR1C1 = "=VLOOKUP(RC[1],Locations,2,FALSE)"
    Target.Offset(0, -1).Value = Target.Offset(0, -1).Value
    End If
    End Sub

    I don’t know what am I supposed to do? Change something if here? That looks like science fiction to me, is that a formula in visual basic?

    On sheet2 (in excel) no changes to the locations when I enter the # and if I erase a cell # nothing happen, it will stay as text not #N/A as you said,

    Pls advise
    Thanks
     
  4. XL Guru

    XL Guru

    Joined:
    Aug 30, 2003
    Messages:
    2,702
    >> ... thank you for the time you've spent ...

    No problem.

    >> On sheet2 (in excel) no changes to the locations
    >> when I enter the # and if I erase a cell # nothing happen,
    >> it will stay as text not #N/A as you said,

    The code is in the sheet module for Sheet1. Therefore you need to perform those actions on Sheet1 for the code to fire.

    Rgds,
    Andy
     
  5. soldtheworld

    soldtheworld Thread Starter

    Joined:
    May 29, 2003
    Messages:
    136
    Ok Guru, It works now, I've only used the vlookup formula (no view code no visual basic)
    Thks (y)
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/246761

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice