ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if this than that macro (https://www.excelbanter.com/excel-programming/399558-if-than-macro.html)

dchristo

if this than that macro
 
I need a macro that will find and place (similar to an if statement)
ex: =if 1 = 1, "1" , if 1 = 2," 2","3"

however, i also need to say if 1 does not equal 1 or 2 etc then 0

Bob Phillips

if this than that macro
 
Do you mean

If Range("A1").Value = 1 Or Range("A1").Value = 2 Then
Range("B1").Value = Range("A1").Value
Else
Range("B1").Value = 0
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dchristo" wrote in message
...
I need a macro that will find and place (similar to an if statement)
ex: =if 1 = 1, "1" , if 1 = 2," 2","3"

however, i also need to say if 1 does not equal 1 or 2 etc then 0




dchristo

if this than that macro
 
In column C

if there is an A, i want to replace with 1
if there is a B, I want to replace with 2
if there is an C, i want to replace with 3
if there is a D, I want to replace with 4

Any other letter, i want to replace with 0

"Bob Phillips" wrote:

Do you mean

If Range("A1").Value = 1 Or Range("A1").Value = 2 Then
Range("B1").Value = Range("A1").Value
Else
Range("B1").Value = 0
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dchristo" wrote in message
...
I need a macro that will find and place (similar to an if statement)
ex: =if 1 = 1, "1" , if 1 = 2," 2","3"

however, i also need to say if 1 does not equal 1 or 2 etc then 0





Mike

if this than that macro
 
You could use a case select property:

Select case letterx

case A
cell.value = 1 (not sure if that is right, but you get the idea)

etc

end select

regards,

mike

"dchristo" wrote:

In column C

if there is an A, i want to replace with 1
if there is a B, I want to replace with 2
if there is an C, i want to replace with 3
if there is a D, I want to replace with 4

Any other letter, i want to replace with 0

"Bob Phillips" wrote:

Do you mean

If Range("A1").Value = 1 Or Range("A1").Value = 2 Then
Range("B1").Value = Range("A1").Value
Else
Range("B1").Value = 0
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dchristo" wrote in message
...
I need a macro that will find and place (similar to an if statement)
ex: =if 1 = 1, "1" , if 1 = 2," 2","3"

however, i also need to say if 1 does not equal 1 or 2 etc then 0





dchristo

if this than that macro
 
does not work for what I am trying to do

"mike" wrote:

You could use a case select property:

Select case letterx

case A
cell.value = 1 (not sure if that is right, but you get the idea)

etc

end select

regards,

mike

"dchristo" wrote:

In column C

if there is an A, i want to replace with 1
if there is a B, I want to replace with 2
if there is an C, i want to replace with 3
if there is a D, I want to replace with 4

Any other letter, i want to replace with 0

"Bob Phillips" wrote:

Do you mean

If Range("A1").Value = 1 Or Range("A1").Value = 2 Then
Range("B1").Value = Range("A1").Value
Else
Range("B1").Value = 0
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"dchristo" wrote in message
...
I need a macro that will find and place (similar to an if statement)
ex: =if 1 = 1, "1" , if 1 = 2," 2","3"

however, i also need to say if 1 does not equal 1 or 2 etc then 0





All times are GMT +1. The time now is 05:19 AM.

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