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