Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default IF statement for lookup matchup

I have the following situation:
User types a currency identifier (text) into a cell in column B, and types
values into two other cells as well, then hits Control-P to run the
GetPipValues macro. We then need to test three conditions before letting the
GetPipValues macro run.
1. Is the user-selected cell in Column B? Our existing code checks that.
2. Is there data in the other two appropriate cells? Existing code and
formula checks that.
3. Does the value the user entered match with a value in a lookup table
range? I need code for this. The lookup table already exists. If no match,
show error message and Exit Sub.

For inserting the Condition 3 check, I have two questions. First, how to
code the Condition 3 check - Does the active cell value match a value in the
lookup table range? Second, how to insert the Condition 3 IF into the
existing IF structure.

Here's the code, with note where I need to insert the Condition 3 test. The
code does work as is, just need to add Condition 3:

Sub OptimumPosition()
'Control-P activates this macro

Dim pcell As String
pcell = ActiveCell.Address

ActiveCell.Select
'CHECK CONDITION 1
If Not Intersect(ActiveCell, Columns("B:B")) Is Nothing Then
'CHECK CONDITION 2, which is determined by a formula in Column 45
ActiveCell.Offset(rowoffset:=0, columnoffset:=45).Select
If ActiveCell = "False" Then 'If Condition 2 NOT met, error
message, and Exit Sub
MsgBox ("Enter data in required fields and re-run Control-p")
Exit Sub
Else 'If Condition 2 IS met,
'NEED TO CHECK CONDITION 3 HERE, before GetPipValues macro runs
GetPipValues 'Run GetPipValues macro
End If

'Additional code here (Working OK, removed for clarity)

'If selected cell IS NOT in Column B, error message & Exit Sub
Else
MsgBox ("Please launch Control-P Hot Key from Column B")
Exit Sub
End If


End Sub


Thanks,
Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default IF statement for lookup matchup

That works, with a little tweaking in the code I didn't show you. Thanks Tim.


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
If statement or lookup statement not sure Renegade40 Excel Worksheet Functions 2 January 18th 09 06:11 AM
If or lookup Statement Chey Excel Discussion (Misc queries) 2 October 24th 08 08:33 PM
How matchup many IDdata- find matched IDdata in long columns wyaj Excel Worksheet Functions 2 October 25th 07 12:13 AM
How do I matchup this criteria? Chase Excel Worksheet Functions 1 October 20th 05 08:08 PM
Index,Matchup Formula Question JDT Excel Discussion (Misc queries) 7 April 16th 05 04:44 PM


All times are GMT +1. The time now is 12:55 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"