Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
John
 
Posts: n/a
Default if statement in Macro

I am trying to write a macro where if cell A1 has a dollar amount put that
cell, however if cell A2 has a dollar amount put that cell. There only can
be one dollar amount, meaning you can have dollar amounts in cells A1 and A2.
This also has to be a macro. Any help would be great
  #2   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi
do you mean

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
end with
msgbox smsg

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
I am trying to write a macro where if cell A1 has a dollar amount put that
cell, however if cell A2 has a dollar amount put that cell. There only
can
be one dollar amount, meaning you can have dollar amounts in cells A1 and
A2.
This also has to be a macro. Any help would be great



  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default


Iif (Range("A1").Value < "" ,Range("A1").Value,Range("A2").Value )

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John" wrote in message
...
I am trying to write a macro where if cell A1 has a dollar amount put that
cell, however if cell A2 has a dollar amount put that cell. There only

can
be one dollar amount, meaning you can have dollar amounts in cells A1 and

A2.
This also has to be a macro. Any help would be great



  #4   Report Post  
John
 
Posts: n/a
Default

HI

I think that is it, but i forgot to mention that if one of the cells has a
dollar amount in it, it needs to put that dollar amount into a different
cell, say A3, instead of the message box

"Frank Kabel" wrote:

Hi
do you mean

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
end with
msgbox smsg

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
I am trying to write a macro where if cell A1 has a dollar amount put that
cell, however if cell A2 has a dollar amount put that cell. There only
can
be one dollar amount, meaning you can have dollar amounts in cells A1 and
A2.
This also has to be a macro. Any help would be great




  #5   Report Post  
Frank Kabel
 
Posts: n/a
Default

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
.range("A3").value=smsg
end with

--
Regards
Frank Kabel
Frankfurt, Germany

John wrote:
HI

I think that is it, but i forgot to mention that if one of the cells
has a dollar amount in it, it needs to put that dollar amount into a
different cell, say A3, instead of the message box

"Frank Kabel" wrote:

Hi
do you mean

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
end with
msgbox smsg

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
I am trying to write a macro where if cell A1 has a dollar amount
put that cell, however if cell A2 has a dollar amount put that
cell. There only can
be one dollar amount, meaning you can have dollar amounts in cells
A1 and A2.
This also has to be a macro. Any help would be great





  #6   Report Post  
John
 
Posts: n/a
Default

Hi, Again

You have been an incredible help. Can i through one more loop into this
whole thing. Lets say that cell A1 is in sheet 1, Cell A2 is in sheet 2, and
cell A3 is in sheet 3. Can this be done? I promise that will be the last
question.

"Frank Kabel" wrote:

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
.range("A3").value=smsg
end with

--
Regards
Frank Kabel
Frankfurt, Germany

John wrote:
HI

I think that is it, but i forgot to mention that if one of the cells
has a dollar amount in it, it needs to put that dollar amount into a
different cell, say A3, instead of the message box

"Frank Kabel" wrote:

Hi
do you mean

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
end with
msgbox smsg

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
I am trying to write a macro where if cell A1 has a dollar amount
put that cell, however if cell A2 has a dollar amount put that
cell. There only can
be one dollar amount, meaning you can have dollar amounts in cells
A1 and A2.
This also has to be a macro. Any help would be great




  #7   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi

if worksheets("sheet1").range("A1").value<"" then
smsg=worksheets("sheet1").range("A1").value
elseif worksheets("sheet2").range("A2").value<"" then
smsg=worksheets("sheet2").range("A2").value
end if
worksheets("sheet3").range("A3").value=smsg
end with

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
Hi, Again

You have been an incredible help. Can i through one more loop into this
whole thing. Lets say that cell A1 is in sheet 1, Cell A2 is in sheet 2,
and
cell A3 is in sheet 3. Can this be done? I promise that will be the last
question.

"Frank Kabel" wrote:

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
.range("A3").value=smsg
end with

--
Regards
Frank Kabel
Frankfurt, Germany

John wrote:
HI

I think that is it, but i forgot to mention that if one of the cells
has a dollar amount in it, it needs to put that dollar amount into a
different cell, say A3, instead of the message box

"Frank Kabel" wrote:

Hi
do you mean

dim smsg
with activesheet
if .range("A1").value<"" then
smsg=.range("A1").value
elseif .range("A2").value<"" then
smsg=.range("A2").value
end if
end with
msgbox smsg

--
Regards
Frank Kabel
Frankfurt, Germany
"John" schrieb im Newsbeitrag
...
I am trying to write a macro where if cell A1 has a dollar amount
put that cell, however if cell A2 has a dollar amount put that
cell. There only can
be one dollar amount, meaning you can have dollar amounts in cells
A1 and A2.
This also has to be a macro. Any help would be great






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
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM
Can you run a macro from an if statement in excel? mstr.cheif Excel Worksheet Functions 3 November 7th 04 09:22 PM


All times are GMT +1. The time now is 09:51 PM.

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

About Us

"It's about Microsoft Excel"