LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ita Ita is offline
external usenet poster
 
Posts: 4
Default worksheet function in event macro

Hi,
I have a code in worksheet_selectionchange that doesnt seem to work.
I intend to do vlookup in column W to Y based on changes column B & C (if
column A ISNUMBER).
When I enter a value in both column B & C, column W to Y wasnt updated even
though the value is there in the lookuptable. Is there something wrong?

Here is the code.

Option Explicit
Dim RowNumber As Long
Dim RLookupDivCC As Variant, SLookupDivCC As String, SLookupUpdDiv As String
Dim SLookupUpdCC As String
Dim RLookupRev As Range, SLookupRev As String, SLookupUpdRev As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
RowNumber = Target.Row

Select Case Target.Column
Case 1
If IsText(Range("A" & RowNumber)) Then
GoTo ENDIT:
Case 2
SLookupDivCC = Range("C" & RowNumber).Value
Set RLookupDivCC = Worksheets("LookUpTable").Range("B1:D100")

Range("W" & RowNumber).Value =
Application.WorksheetFunction.VLookup(SLookupDivCC , RLookupDivCC, 2, False)
Range("X" & RowNumber).Value =
Application.WorksheetFunction.VLookup(SLookupDivCC , RLookupDivCC, 3, False)
Case 3
SLookupRev = Range("B" & RowNumber).Value
Set RLookupRev = Worksheets("LookUpTable").Range("E1:F50")

Range("Y" & RowNumber).Value =
Application.WorksheetFunction.VLookup(SLookupRev, RLookupRev, 2, False)
End Select

ENDIT
Application.EnableEvents = True

End Sub

thank you
ITA
 
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
Delete a Column when in a Macro-Worksheet Event? jeannie v Excel Worksheet Functions 2 July 19th 07 01:58 AM
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
Event macro that targets specific worksheet retseort Excel Discussion (Misc queries) 3 February 20th 06 02:47 PM
It seems to me that I need an event Macro, nick s Excel Worksheet Functions 8 November 28th 05 05:37 PM
Event Macro stevepain Excel Discussion (Misc queries) 6 August 5th 05 05:11 AM


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

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

About Us

"It's about Microsoft Excel"