Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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



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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"