Friday, April 13, 2012 2:06 AM
I am having some difficulties trying to fine a way using VLOOKUP to get the result of the content of a range. Here is my problem:
In my workbook I have a main menu sheet name (Main) where the cell address to receive the response is in "F6" in the worksheet within the same workbook, the sheet named (201) a range of status can contain the following value: either "OPEN" or "CLOSED" now. should any of the cell in this range contains a "CLOSED" Statusfirst I need to change the status of all the cells within that range to "CLOSED" so the main menu sheet (Main) address "F6" would result in "CLOSED" but if nothing is found with the range then return a BLANK otherwise a status of "OPEN" must be set for the cell "F6" in Main sheet. The range in sheet (201) is E6:E25
How to do it? I could not find a way to do that. Your help will be very appreciated. By the way, I am new to vba and need someone to write the formula or a macro to do that.
P.S.: The underlined and bold statement can be skipped since the objective is to get as a result if one is closed and make sure that F6 gets the status "CLOSED"
Thanks in advance.
- Edited by chamdan Friday, April 13, 2012 3:16 AM Possible solution
Friday, April 13, 2012 9:09 AM
You can't unless you write a macro. The problem is you need to change a value before you do the lookup which will cause a "circular formula" which will create an error.
You can do everything in a macro. I think in this case it is better to use a formula in F6. run the macro below which will change the data in sheet 201. After the macro is run the formula in F6 will be correct.
Use the formula in F6
Set LookupRange = .Range("E6:E25")
Set ResponseCell = .Range("F6")
Set c = LookupRange.Find(What:="CLOSED", _
If Not c Is Nothing Then
LookupRange.Value = "CLOSED"
Friday, April 13, 2012 10:42 AMModerator
Not sure I follow but if the only objective is to return the following to F6 depending on the contents in 201:E6:E25
Blank: if all cells in are blank
"OPEN": if all cells contain "OPEN"
"CLOSED: any other set of contents
After testing change "bank" to ""
If the reference will definitely always be E6:E25 could change ROWS('201'!E6:E25) to 20
Might be easier to Name E6:E25
Friday, April 13, 2012 10:57 AM
I will give it a try and will let you know.
Friday, April 13, 2012 10:58 AM
Thanks peter, I will let you know after testing it.
Saturday, April 14, 2012 4:15 AM
Hi Joel and Peter,Thanks for your help.
I have tested the formula but had a problem I have finally used Joel's formula and adjusted it to fit what I am trying to get as a result and now works perfectly. I have adapted the formula and applied it to each of the rows where necessary. Here is the adjustment I made:
Thank you and will mark it as answered.
- Marked As Answer by chamdan Saturday, April 14, 2012 4:15 AM