Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can a Macro contain an IF statement? How?

When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can a Macro contain an IF statement? How?

Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can a Macro contain an IF statement? How?

Thank you, Norman. I never would have figured that one out by myself.
That's a huge help!

"Norman Jones" wrote:

Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Can a Macro contain an IF statement? How?

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can a Macro contain an IF statement? How?

Maybe you should read the replies before you spit your hatred from your rude
pie-hole. Unfortunately, I had to get some sleep after my initial post.
When I arose this morning I read and used Norman's very helpful solution. I
told him so in the "thank you" reply that I posted... an hour before your
posted sanctimonious lecture.

Looks like you're the "jerk", Choate!

"R. Choate" wrote:

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Can a Macro contain an IF statement? How?

Your reply to Norman must be one of those "phantom thank-you's" that just doesn't show up in the same thread. Also, it wasn't you
who was being called a jerk, it was the other guy who was getting help from Bob, but wasn't satisfied after an hour so he re-posted
the same problem. I didn't lecture you at all. My note was to Norman, not to you, and it is still valid. Call me whatever you want.

--
RMC,CPA


"MysticMarley" wrote in message ...
Maybe you should read the replies before you spit your hatred from your rude
pie-hole. Unfortunately, I had to get some sleep after my initial post.
When I arose this morning I read and used Norman's very helpful solution. I
told him so in the "thank you" reply that I posted... an hour before your
posted sanctimonious lecture.

Looks like you're the "jerk", Choate!

"R. Choate" wrote:

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can a Macro contain an IF statement? How?

I accept your apology.

"R. Choate" wrote:

Your reply to Norman must be one of those "phantom thank-you's" that just doesn't show up in the same thread. Also, it wasn't you
who was being called a jerk, it was the other guy who was getting help from Bob, but wasn't satisfied after an hour so he re-posted
the same problem. I didn't lecture you at all. My note was to Norman, not to you, and it is still valid. Call me whatever you want.

--
RMC,CPA


"MysticMarley" wrote in message ...
Maybe you should read the replies before you spit your hatred from your rude
pie-hole. Unfortunately, I had to get some sleep after my initial post.
When I arose this morning I read and used Norman's very helpful solution. I
told him so in the "thank you" reply that I posted... an hour before your
posted sanctimonious lecture.

Looks like you're the "jerk", Choate!

"R. Choate" wrote:

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Can a Macro contain an IF statement? How?

Dear Sir,

If you thanked Norman and it just didn't appear in the thread, then I do apologize to you for offending you. My comments were more
general in nature and they are true. Guys like Norman are VERY generous with their time and extremely helpful. Tom Ogilvy, Bob
Phillips, and all of the MVPs do a lot for all of us, and they've been doing it for years. I'm sure the other guy is going to be a
lot more ****ed at me than you are, but he deserves the lecture, sanctimonious or not. I just happened to pick your thread to make
my comment to Norman. I didn't see your follow-up with him and still can't find it, but if you say it is there, then I believe you.

Richard, Pie-hole, Choate
--
RMC,CPA


"MysticMarley" wrote in message ...
I accept your apology.

"R. Choate" wrote:

Your reply to Norman must be one of those "phantom thank-you's" that just doesn't show up in the same thread. Also, it wasn't you
who was being called a jerk, it was the other guy who was getting help from Bob, but wasn't satisfied after an hour so he
re-posted
the same problem. I didn't lecture you at all. My note was to Norman, not to you, and it is still valid. Call me whatever you
want.

--
RMC,CPA


"MysticMarley" wrote in message
...
Maybe you should read the replies before you spit your hatred from your rude
pie-hole. Unfortunately, I had to get some sleep after my initial post.
When I arose this morning I read and used Norman's very helpful solution. I
told him so in the "thank you" reply that I posted... an hour before your
posted sanctimonious lecture.

Looks like you're the "jerk", Choate!

"R. Choate" wrote:

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the
help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls
himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy
wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked
or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.










  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can a Macro contain an IF statement? How?

Thank you, Richard. And I apologize to you for being so angry. Maybe I
should have stayed in bed another hour or so longer. I just didn't want my
ID associated with someone with a bad rep. I've only come here twice in the
past few months looking for answers. Both times I got the exact help that I
needed within a few hours. Both times have also been life-savers. I've also
posted my appreciation on both occasions. I wouldn't want to have trouble
finding help in the future because "mysticmarley" was linked "jerk".

Anyway, here's the thank you that was posted to Norman (08:00 PST):

"Thank you, Norman. I never would have figured that one out by myself.
That's a huge help!"

I hope he didn't have problems finding it.

Cheers,

Peter B.

"R. Choate" wrote:

Dear Sir,

If you thanked Norman and it just didn't appear in the thread, then I do apologize to you for offending you. My comments were more
general in nature and they are true. Guys like Norman are VERY generous with their time and extremely helpful. Tom Ogilvy, Bob
Phillips, and all of the MVPs do a lot for all of us, and they've been doing it for years. I'm sure the other guy is going to be a
lot more ****ed at me than you are, but he deserves the lecture, sanctimonious or not. I just happened to pick your thread to make
my comment to Norman. I didn't see your follow-up with him and still can't find it, but if you say it is there, then I believe you.

Richard, Pie-hole, Choate
--
RMC,CPA


"MysticMarley" wrote in message ...
I accept your apology.

"R. Choate" wrote:

Your reply to Norman must be one of those "phantom thank-you's" that just doesn't show up in the same thread. Also, it wasn't you
who was being called a jerk, it was the other guy who was getting help from Bob, but wasn't satisfied after an hour so he
re-posted
the same problem. I didn't lecture you at all. My note was to Norman, not to you, and it is still valid. Call me whatever you
want.

--
RMC,CPA


"MysticMarley" wrote in message
...
Maybe you should read the replies before you spit your hatred from your rude
pie-hole. Unfortunately, I had to get some sleep after my initial post.
When I arose this morning I read and used Norman's very helpful solution. I
told him so in the "thank you" reply that I posted... an hour before your
posted sanctimonious lecture.

Looks like you're the "jerk", Choate!

"R. Choate" wrote:

Hi Norman,

You know, people used to be very gracious when they got help here. Now I almost never even see anybody say thank you for the
help
they just got. Here you helped this guy hours ago and he didn't even say thank you. I chewed some other guy out who calls
himself
"Kamakshi" because he was rudely dismissing the help he got from Bob Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so he could do some needed reading. Since this guy
wouldn't
thank you for helping him, I will. Thank you for helping this person and anybody else you help, even when you don't get thanked
or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.










  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Can a Macro contain an IF statement? How?

Hi Richard,

Speaking purely from a personal perspective, I do not feel it incumbent upon
a poster to respond to proffered assistance with thanks - which is not to
say that it is other than rewarding if they do!

If I choose to respond to a posted question, it is primarily a selfish
reaction: the pleasure that *I* derive and the concomitant self-learning
experience considerably outweigh the dubious merits of my response.

Of course, I must now thank you and I do so, not from any sense of
obligation, but in appreciation of your sentiments

As an aside, 'missing' posts can make fools of all of us: nobody, I am sure,
feels more foolish than I do when, having posted a response to the NG, I
subsequently discover responses that are not only notably superior but
significantly pre-date my efforts.I am afraid that 'phantom' or missing
posts are an integral part of the newsresder experience.

Thank you again, Richard!


---
Regards,
Norman



"R. Choate" wrote in message
...
Hi Norman,

You know, people used to be very gracious when they got help here. Now I
almost never even see anybody say thank you for the help
they just got. Here you helped this guy hours ago and he didn't even say
thank you. I chewed some other guy out who calls himself
"Kamakshi" because he was rudely dismissing the help he got from Bob
Phillips and just re-posting the problem again just an hour
later. Such a jerk. I sent him a link to the Newsgroup netiquette site so
he could do some needed reading. Since this guy wouldn't
thank you for helping him, I will. Thank you for helping this person and
anybody else you help, even when you don't get thanked or
acknowledged in any way.

Richard
--
RMC,CPA


"Norman Jones" wrote in message
...
Hi MysticMarley:

Here is a simple example:

'===============
Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A1")

With rng
If .Value 100 Then
'Do something, e.g.:
.Interior.ColorIndex = 3
Else
'Do something else, e.g.:
.Interior.ColorIndex = 5
End If
End With
End Sub

'<<===============

---
Regards,
Norman



"MysticMarley" wrote in message
...
When my macro starts, I would like for it to reference a value from a
cell
then perform one of two actions based upon the value. Is this possible?
Please, explain how.






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 statement in macro Aline Excel Worksheet Functions 4 September 30th 08 07:40 PM
Run Macro From If Statement Paige Excel Discussion (Misc queries) 2 June 2nd 05 10:37 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
HELP w/ Macro and IF Statement randy_tn Excel Programming 1 November 3rd 04 01:49 AM
Macro statement Sheela Excel Programming 1 September 2nd 03 10:17 AM


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