Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
in G25 put :
=IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hiya, Thanks for the info - I did have that in place, when I was testing to see whether I could get it to work. Problem is I have several values to check for and several results to display, so I need to put this into VB and an 'elseif' statement. Any ideas? Thanks again, Sian "Toppers" wrote: in G25 put : =IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sian
Depending on how complex the rules are, it might still be possible to do what you want without using VBA, which would be my preference.: for example something like =IF(I10="Test","Testing","Normal")&IF(I6="US","US" ,"Non-US") You might also be able to use a lookup table and the VLOOKUP function to translate the i10 and i6 values to what you want. However, if you're definitely set on using VBA, then there are two ways you could go about it: either a macro that you run on demand or on some Event, e.g. Worksheet_Calculate, that puts the value into G25. This would look something like Sub SetG25() Dim i10Val, i6Val, g25Val i10Val = ThisWorkbook.Sheets("Sheetname").Range("I10") i6Val = ThisWorkbook.Sheets("Sheetname").Range("I6") if I10Val = "Test" and i6Val="US" Then g25Val = "TestingUS" elseif I10Val = "Test" and i6Val="France" Then g25Val = "TestingFrance" elseif .... etc else ' default g25Val = "Invalid entries in I6/I10" End if ThisWorkbook.Sheets("Sheetname").Range("G25") = g25Val End Sub or (preferably IMO), you could make a user-defined function to return the correct value. In G25 you would put =myFunc(I10, I6) and in VBA: Function myFunc(v1, v2) if v1 = "Test" and v2 ="US" Then myFunc = "TestingUS" elseif .... etc as before else ' default myFunc = "Invalid entries" End if End Function hope this helps Andrew Taylor SianH wrote: Hiya, Thanks for the info - I did have that in place, when I was testing to see whether I could get it to work. Problem is I have several values to check for and several results to display, so I need to put this into VB and an 'elseif' statement. Any ideas? Thanks again, Sian "Toppers" wrote: in G25 put : =IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
in VB
If application.and(range("i6")="US",range("I10")="Tes t") then Range("G25")="TestingUS" Else If application.and(range("i7")="UK",range("I10")="Tes t") then Range("G25")="TestingUK" End iF End if HTH "SianH" wrote: Hiya, Thanks for the info - I did have that in place, when I was testing to see whether I could get it to work. Problem is I have several values to check for and several results to display, so I need to put this into VB and an 'elseif' statement. Any ideas? Thanks again, Sian "Toppers" wrote: in G25 put : =IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() That's great, thank you. Can I be a real pain and now ask whether I can change this to display values in a named list rather than an actual value? (another thing I want to do!). I can do a validation, but it always gives me a drop down list, and I just want to display the full list straight off without a drop down. :-) "Toppers" wrote: in VB If application.and(range("i6")="US",range("I10")="Tes t") then Range("G25")="TestingUS" Else If application.and(range("i7")="UK",range("I10")="Tes t") then Range("G25")="TestingUK" End iF End if HTH "SianH" wrote: Hiya, Thanks for the info - I did have that in place, when I was testing to see whether I could get it to work. Problem is I have several values to check for and several results to display, so I need to put this into VB and an 'elseif' statement. Any ideas? Thanks again, Sian "Toppers" wrote: in G25 put : =IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sian,
Do you mean you have a named range called (for exampe"MyList") and you want to display the nth item? Can you give an example? "SianH" wrote: That's great, thank you. Can I be a real pain and now ask whether I can change this to display values in a named list rather than an actual value? (another thing I want to do!). I can do a validation, but it always gives me a drop down list, and I just want to display the full list straight off without a drop down. :-) "Toppers" wrote: in VB If application.and(range("i6")="US",range("I10")="Tes t") then Range("G25")="TestingUS" Else If application.and(range("i7")="UK",range("I10")="Tes t") then Range("G25")="TestingUK" End iF End if HTH "SianH" wrote: Hiya, Thanks for the info - I did have that in place, when I was testing to see whether I could get it to work. Problem is I have several values to check for and several results to display, so I need to put this into VB and an 'elseif' statement. Any ideas? Thanks again, Sian "Toppers" wrote: in G25 put : =IF(AND(I6="US",I10="Test"),"TestingUS","") HTH "SianH" wrote: Hi all, I wonder if someone can help ... I'm constructing a statement that checks two cells for values, if those values are as expected, then another cell should display a specific value. i.e. : If I6 = "US" And I10 = "Test" Then G25 = "TestingUS" I'd like the value to appear in the G25 cell (basically so I can use it for other things). I don't know that much about VB, hence why I'm getting stuck on how to get it to actually insert the value into the G25 cell. Any help would be greatly appreciated! Thanks, Sian |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF statements - use to insert/delete rows? | Excel Worksheet Functions | |||
IF text statements | Excel Worksheet Functions | |||
Insert IF-statements by Script, very slow. | Excel Programming | |||
How to create insert statements? | Excel Programming | |||
Insert cell/format/text/fontsize and auto insert into header? | Excel Programming |