Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using IF statements to insert text

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Using IF statements to insert text

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using IF statements to insert text


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Using IF statements to insert text

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Using IF statements to insert text

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using IF statements to insert text


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Using IF statements to insert text

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
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 statements - use to insert/delete rows? WRM Excel Worksheet Functions 5 October 21st 06 08:55 PM
IF text statements CRVDiva Excel Worksheet Functions 6 October 31st 05 11:44 PM
Insert IF-statements by Script, very slow. Parity[_2_] Excel Programming 2 October 24th 05 12:24 PM
How to create insert statements? mooreeasyvibe Excel Programming 2 August 31st 05 03:56 PM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


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