ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Statement (https://www.excelbanter.com/excel-programming/353203-if-statement.html)

STEVEB

If Statement
 

Does anyone have any suggestions to look at column A and:

In column A:
If Cell.Value = "005" Then
Colum B Cell Value="AAA"
In column A:
If Cell.Value = "102" Then
Colum B Cell Value="BBB"
In column A:
If Cell.Value = "109" Then
Colum B Cell Value="CCC"
In column A:
If Cell.Value = "112" Then
Colum B Cell Value="DDD"
In column A:
If Cell.Value = "641" Then
Colum B Cell Value="EEE"
In column A:
If Cell.Value = "2090" Then
Colum B Cell Value="FFF"

Any help would be greatly appreciated!


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=511966


Mark

If Statement
 
Try this:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim NewValue As String
If Target.Column = 1 Then
Select Case Target.Text
Case Is = "005", "5"
NewValue = "AAA"
Case Is = "102"
NewValue = "BBB"
Case Is = "109"
NewValue = "CCC"
Case Is = "112"
NewValue = "DDD"
Case Is = "641"
NewValue = "EEE"
Case Is = "2090"
NewValue = "FFF"
End Select
Target.Offset(0, 1) = NewValue
End If

End Sub

This assumes that you want the Triple letters to occurr right next to
your exixting numbers.


STEVEB

If Statement
 

Thanks Mark, I appreciate your help!

I receive the following error messsage:

Run Time Error 424 - Object required

At this line:

If Target.Column = 1 Then

Any sugestions?

Thank

--
STEVE
-----------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...nfo&userid=187
View this thread: http://www.excelforum.com/showthread.php?threadid=51196


avveerkar[_56_]

If Statement
 

STEVEB Wrote:
Does anyone have any suggestions to look at column A and:

In column A:
If Cell.Value = "005" Then
Colum B Cell Value="AAA"
In column A:
If Cell.Value = "102" Then
Colum B Cell Value="BBB"
In column A:
If Cell.Value = "109" Then
Colum B Cell Value="CCC"
In column A:
If Cell.Value = "112" Then
Colum B Cell Value="DDD"
In column A:
If Cell.Value = "641" Then
Colum B Cell Value="EEE"
In column A:
If Cell.Value = "2090" Then
Colum B Cell Value="FFF"

Any help would be greatly appreciated!


Instead of VBA you could have a nested IF formula in B1

=IF(A1="005","AAA",IF(A1="102","BBB",IF(A1="109"," CCC",IF(A1="112","DDD",IF(A1="641","EEE",IF(A1="20 90","FFF",""))))))
And then autofill to all the cells (B2 onward) in col B.

I am assuming that col A has text characters not numbers. eg if A1
="102" then B1 = "BBB" asssumes A1 is character string. If it is number
then change formula by removing quotes around A1 value. eg A1=102
instead of A1="102"

A V Veerkar


--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=511966


STEVEB

If Statement
 

A V

Thanks for the suggestion..It worked!!


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile: http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=511966


avveerkar[_57_]

If Statement
 

STEVEB Wrote:
Thanks Mark, I appreciate your help!

I receive the following error messsage:

Run Time Error 424 - Object required

At this line:

If Target.Column = 1 Then

Any sugestions?

Thanks


Mark's routine seems to be OK. Just check that you have copied i
correctly. Also I hope the procedure is on the code sheet of you
worksheet. ( Rightclick the worksheet tab and then click 'view code'
Paste the procedure given by Mark on this code sheet.) It should work.

A V Veerka

--
avveerka
-----------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...fo&userid=3033
View this thread: http://www.excelforum.com/showthread.php?threadid=51196


avveerkar[_58_]

If Statement
 

STEVEB Wrote:
A V

Thanks for the suggestion..It worked!!


You are welcome.

A V Veerka

--
avveerka
-----------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...fo&userid=3033
View this thread: http://www.excelforum.com/showthread.php?threadid=51196



All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com