+ Reply to Thread
Results 1 to 4 of 4

Returning a value dependant on a cell...

  1. #1
    RemySS
    Guest

    Returning a value dependant on a cell...

    Hi Everyone,

    I have two tables, the first lists letters from AA to ZZ in a lookup type
    list and when on of these is selected, for example AB, the corresponding cell
    in the second table (the equivalent AB) is populated with a Y.

    Table A: Table B:

    Type Site Controls Type Has Site Control
    AA (various data) AA Y
    AB " AB Y
    DZ " DZ Y
    LW " LW Y

    So, as the data is selected in table A, the Y should be populated in table
    B. I would appreciate the help on this as it would speed up my tasks
    considerably.

    Thanks in advance,

    Remy


  2. #2
    Bob Phillips
    Guest

    Re: Returning a value dependant on a cell...

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim iPos As Long
    If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    With Target
    iPos = Application.Match(Target.Value, Range("M:M"), 0)
    If iPos > 0 Then
    Cells(iPos, "N").Value = "Y"
    End If
    End With
    End If
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.

    This assumes the first table is A1:Bn, and the second is M1:Mn. Change to
    suit.

    --
    HTH

    Bob Phillips

    "RemySS" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Everyone,
    >
    > I have two tables, the first lists letters from AA to ZZ in a lookup type
    > list and when on of these is selected, for example AB, the corresponding

    cell
    > in the second table (the equivalent AB) is populated with a Y.
    >
    > Table A: Table B:
    >
    > Type Site Controls Type Has Site Control
    > AA (various data) AA Y
    > AB " AB Y
    > DZ " DZ Y
    > LW " LW Y
    >
    > So, as the data is selected in table A, the Y should be populated in table
    > B. I would appreciate the help on this as it would speed up my tasks
    > considerably.
    >
    > Thanks in advance,
    >
    > Remy
    >




  3. #3
    RemySS
    Guest

    Re: Returning a value dependant on a cell...

    Bob,

    Thanks for the code, I've tried to implement as you said. However, even
    after changing the table ranges I got no response from the code, it did
    nothing except to give me an error (13) stating a type mismatch...any further
    help you could provide?

    "Bob Phillips" wrote:

    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Dim iPos As Long
    > If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    > With Target
    > iPos = Application.Match(Target.Value, Range("M:M"), 0)
    > If iPos > 0 Then
    > Cells(iPos, "N").Value = "Y"
    > End If
    > End With
    > End If
    > End Sub
    >
    > 'This is worksheet event code, which means that it needs to be
    > 'placed in the appropriate worksheet code module, not a standard
    > 'code module. To do this, right-click on the sheet tab, select
    > 'the View Code option from the menu, and paste the code in.
    >
    > This assumes the first table is A1:Bn, and the second is M1:Mn. Change to
    > suit.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "RemySS" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi Everyone,
    > >
    > > I have two tables, the first lists letters from AA to ZZ in a lookup type
    > > list and when on of these is selected, for example AB, the corresponding

    > cell
    > > in the second table (the equivalent AB) is populated with a Y.
    > >
    > > Table A: Table B:
    > >
    > > Type Site Controls Type Has Site Control
    > > AA (various data) AA Y
    > > AB " AB Y
    > > DZ " DZ Y
    > > LW " LW Y
    > >
    > > So, as the data is selected in table A, the Y should be populated in table
    > > B. I would appreciate the help on this as it would speed up my tasks
    > > considerably.
    > >
    > > Thanks in advance,
    > >
    > > Remy
    > >

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Returning a value dependant on a cell...

    Try this slightly amended version

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim iPos As Long
    If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    With Target
    On Error Resume Next
    iPos = Application.Match(Target.Value, Range("M:M"), 0)
    On Error GoTo 0
    If iPos > 0 Then
    Cells(iPos, "N").Value = "Y"
    End If
    End With
    End If
    End Sub


    --
    HTH

    Bob Phillips

    "RemySS" <[email protected]> wrote in message
    news:[email protected]...
    > Bob,
    >
    > Thanks for the code, I've tried to implement as you said. However, even
    > after changing the table ranges I got no response from the code, it did
    > nothing except to give me an error (13) stating a type mismatch...any

    further
    > help you could provide?
    >
    > "Bob Phillips" wrote:
    >
    > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > > Dim iPos As Long
    > > If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
    > > With Target
    > > iPos = Application.Match(Target.Value, Range("M:M"), 0)
    > > If iPos > 0 Then
    > > Cells(iPos, "N").Value = "Y"
    > > End If
    > > End With
    > > End If
    > > End Sub
    > >
    > > 'This is worksheet event code, which means that it needs to be
    > > 'placed in the appropriate worksheet code module, not a standard
    > > 'code module. To do this, right-click on the sheet tab, select
    > > 'the View Code option from the menu, and paste the code in.
    > >
    > > This assumes the first table is A1:Bn, and the second is M1:Mn. Change

    to
    > > suit.
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "RemySS" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi Everyone,
    > > >
    > > > I have two tables, the first lists letters from AA to ZZ in a lookup

    type
    > > > list and when on of these is selected, for example AB, the

    corresponding
    > > cell
    > > > in the second table (the equivalent AB) is populated with a Y.
    > > >
    > > > Table A: Table B:
    > > >
    > > > Type Site Controls Type Has Site Control
    > > > AA (various data) AA Y
    > > > AB " AB Y
    > > > DZ " DZ Y
    > > > LW " LW Y
    > > >
    > > > So, as the data is selected in table A, the Y should be populated in

    table
    > > > B. I would appreciate the help on this as it would speed up my tasks
    > > > considerably.
    > > >
    > > > Thanks in advance,
    > > >
    > > > Remy
    > > >

    > >
    > >
    > >




+ 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