Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
SATB
 
Posts: n/a
Default Macro and If Statement

Here's the situation: I have a worksheet that will have an "X" in
either cell F3 or G3 or H3. What I would like to do (via a macro), is
to examine F3, G3 and H3, and if there is an "X" in anyone of those
cells, to run another specific macro.

For example:

Run a macro (for example called "totalsummary")to determine...

If there is an "X" in F3, then run a macro called "summaryEL";
If there is an "X" in G3, then run a macro called "summaryHT";
If there is an "X" in H3, then run a macro called "summaryFA".

This has to be a macro that starts this process, rather than an if
statement, as I wish to control when this process will happen seperate
from the condition.

In other words, the macro that I run will have if statements imbedded,
and if anyone one of those if statements are true (as it will be only
one), the result is antoher seperate macro running.

Is this a long way of doing this, or is there a better way.

Thanks in advance.

Pete
  #2   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi
one way:

'....
with activesheet.range("F3")
if .value="X" then
summaryEL
elseif .offset(0,1).value)="X" then
summaryHT
elseif .offset(0,2).value)="X" then
summaryFA
end if
end with
'...

--
Regards
Frank Kabel
Frankfurt, Germany

"SATB" schrieb im Newsbeitrag
m...
Here's the situation: I have a worksheet that will have an "X" in
either cell F3 or G3 or H3. What I would like to do (via a macro), is
to examine F3, G3 and H3, and if there is an "X" in anyone of those
cells, to run another specific macro.

For example:

Run a macro (for example called "totalsummary")to determine...

If there is an "X" in F3, then run a macro called "summaryEL";
If there is an "X" in G3, then run a macro called "summaryHT";
If there is an "X" in H3, then run a macro called "summaryFA".

This has to be a macro that starts this process, rather than an if
statement, as I wish to control when this process will happen

seperate
from the condition.

In other words, the macro that I run will have if statements

imbedded,
and if anyone one of those if statements are true (as it will be only
one), the result is antoher seperate macro running.

Is this a long way of doing this, or is there a better way.

Thanks in advance.

Pete


  #3   Report Post  
SATB
 
Posts: n/a
Default

Frank: Thanks very much for your suggestion...however there was a
slight error when it went to the "elseif.offset(0,1).value..."
statement. I modified the macro as follows, and it worked great...

Sub summary()
'
With ActiveSheet.Range("F3")
If .Value = "X" Then
summaryEL
ElseIf ActiveSheet.Range("G3") = "X" Then
summaryHT
ElseIf ActiveSheet.Range("H3") = "X" Then
summaryFA
End If
End With
End Sub

Again, thanks for your help.
Pete


"Frank Kabel" wrote in message ...
Hi
one way:

'....
with activesheet.range("F3")
if .value="X" then
summaryEL
elseif .offset(0,1).value)="X" then
summaryHT
elseif .offset(0,2).value)="X" then
summaryFA
end if
end with
'...

--
Regards
Frank Kabel
Frankfurt, Germany

"SATB" schrieb im Newsbeitrag
m...
Here's the situation: I have a worksheet that will have an "X" in
either cell F3 or G3 or H3. What I would like to do (via a macro), is
to examine F3, G3 and H3, and if there is an "X" in anyone of those
cells, to run another specific macro.

For example:

Run a macro (for example called "totalsummary")to determine...

If there is an "X" in F3, then run a macro called "summaryEL";
If there is an "X" in G3, then run a macro called "summaryHT";
If there is an "X" in H3, then run a macro called "summaryFA".

This has to be a macro that starts this process, rather than an if
statement, as I wish to control when this process will happen

seperate
from the condition.

In other words, the macro that I run will have if statements

imbedded,
and if anyone one of those if statements are true (as it will be only
one), the result is antoher seperate macro running.

Is this a long way of doing this, or is there a better way.

Thanks in advance.

Pete

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 help Jeff Garrett Excel Discussion (Misc queries) 11 December 1st 04 08:47 PM
macro - adding rows to a column that is summed HGood Excel Discussion (Misc queries) 2 December 1st 04 03:28 PM
Date and Time Macro m.j.anderson Excel Discussion (Misc queries) 1 December 1st 04 12:35 AM
macro interruption: help!!! mario milani Excel Discussion (Misc queries) 1 November 30th 04 06:02 PM
Macro for Show/Hide Column Andy Excel Discussion (Misc queries) 2 November 26th 04 01:03 PM


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