Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default lookup formula or a macro?

Hi

I have 2 sheets. There are one string like E1234 and one date on each sheets in one row...

E1234 11/11/2007
E5846 12/10/2007


The strings are the same in the two sheets in the same columns but they are in different rows related to the other sheet. My aim is: if one date has changed, the date would change on the other sheet also according to the string.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default lookup formula or a macro?


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim iRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
On Error Resume Next
iRow = Application.Match(.Offset(0, -1).Value,
Worksheets("Sheet2").Columns(1), 0)
On Error GoTo 0
If iRow 0 Then
Worksheets("Sheet2").Cells(iRow, "B").Value = .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
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.


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"tomi12619" <tomi12619@laptop wrote in message
...
Hi

I have 2 sheets. There are one string like E1234 and one date on each sheets
in one row...

E1234 11/11/2007
E5846 12/10/2007


The strings are the same in the two sheets in the same columns but they are
in different rows related to the other sheet. My aim is: if one date has
changed, the date would change on the other sheet also according to the
string.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default lookup formula or a macro?

It isn't work properly, but thank you for your help. I can see the way
of the solution.

On nov. 12, 00:43, "Bob Phillips" wrote:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim iRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
On Error Resume Next
iRow = Application.Match(.Offset(0, -1).Value,
Worksheets("Sheet2").Columns(1), 0)
On Error GoTo 0
If iRow 0 Then
Worksheets("Sheet2").Cells(iRow, "B").Value = .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
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.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"tomi12619" <tomi12619@laptop wrote in message

...
Hi

I have 2 sheets. There are one string like E1234 and one date on each sheets
in one row...

E1234 11/11/2007
E5846 12/10/2007

The strings are the same in the two sheets in the same columns but they are
in different rows related to the other sheet. My aim is: if one date has
changed, the date would change on the other sheet also according to the
string.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Utilizing a RANDBETWEEN() formula within a LOOKUP formula Rich Werk. Excel Discussion (Misc queries) 4 November 4th 09 03:01 AM
lookup macro BMI Excel Discussion (Misc queries) 0 February 18th 08 03:10 PM
Is it possible...lookup macro Haxer Excel Programming 5 August 4th 07 08:50 AM
Using Lookup in a macro Fred Smith Excel Programming 1 March 10th 07 04:18 AM
Lookup Formula - but have a formula if it can't find/match a value Stephen Excel Worksheet Functions 11 June 14th 05 05:32 AM


All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"