PDA

View Full Version : Solved: Return contents of row ?4...



Sir Babydum GBE
10-13-2005, 05:20 AM
Can I do this?:

Let's say E4 contains "Apples", and F4 contains "Oranges"

If I click a cell anywhere in column E, C3 will return "Apples", whereas if I select a cell in F, then C3 will contain "Oranges"

Thanks

Paleo
10-13-2005, 05:37 AM
At the WorkSheet macros simply type:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CelulaAtiva As String
CelulaAtiva = ActiveCell.Address(False, False)
If Left(CelulaAtiva, 1) = "E" Then
Range("C3") = Range("E4")
ElseIf Left(CelulaAtiva, 1) = "F" Then
Range("C3") = Range("F4")
Else
Range("C3") = ""
End If
End Sub

johnske
10-13-2005, 05:38 AM
Can I do this?:

Let's say E4 contains "Apples", and F4 contains "Oranges"

If I click a cell anywhere in column E, C3 will return "Apples", whereas if I select a cell in F, then C3 will contain "Oranges"

ThanksSure you can do it...put this in a worksheet modulePrivate Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("E:E")) Is Nothing Then
[C3] = [E4]
ElseIf Not Application.Intersect(Target, Columns("F:F")) Is Nothing Then
[C3] = [F4]
End If
End SubEnjoy :)

EDIT: Shorter alternativePrivate Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 5 Then
[C3] = [E4]
ElseIf Target.Column = 6 Then
[C3] = [F4]
End If
End Sub

Sir Babydum GBE
10-13-2005, 05:50 AM
Thanks Paleo - Magic!

Sir Babydum GBE
10-13-2005, 06:03 AM
Wow! Spoilt for choice!

Thanks both.

Paleo
10-14-2005, 02:00 PM
Hi Babydum,

so, is it solved?