Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Syntax for running a macro from an =IF function?

Hi,

I want to run a macro that simply moves data from one row
to an area of the worksheet that keeps track of completed
items. What I need is a statement that does something
like this:

=IF(b1="",do nothing, run move macro).

How do I tell the =IF function to run the macro? This
seems to be a pretty easy thing to go yet the Help does
not address it.

Thanks,

Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Syntax for running a macro from an =IF function?

You can't really call Sub type procedures from within worksheet
formulas. A function called from a worksheet formula can only
return a result to the calling cell. You might be able to use the
Change or Calculate event procedure to do what you want. Perhaps
you could provide a few more details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"BobH" wrote in message
...
Hi,

I want to run a macro that simply moves data from one row
to an area of the worksheet that keeps track of completed
items. What I need is a statement that does something
like this:

=IF(b1="",do nothing, run move macro).

How do I tell the =IF function to run the macro? This
seems to be a pretty easy thing to go yet the Help does
not address it.

Thanks,

Bob



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Syntax for running a macro from an =IF function?

What I have is a place in a spreadsheet for people to put
in action items and a complete date (I know, there are
much better tools for this, but this is the tool they want
to use). If there is a completion date (i.e. it isn't
blank) then I want to move that entry down to a separate
section containing completed actions.

My thought was to write a macro that checked each cell for
a completed date and if it contained an entry to simply
cut and paste it onto the end of the list at the bottom.

Thanks for your help.

Bob






-----Original Message-----
Hi,

I want to run a macro that simply moves data from one row
to an area of the worksheet that keeps track of completed
items. What I need is a statement that does something
like this:

=IF(b1="",do nothing, run move macro).

How do I tell the =IF function to run the macro? This
seems to be a pretty easy thing to go yet the Help does
not address it.

Thanks,

Bob
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Syntax for running a macro from an =IF function?

Bob
Here is an event macro that reacts when an entry is made in column D.
The macro copies Columns A:D of that row and pastes it to the bottom of the
data range in Column A. It then deletes the row of the original entry.
You will probably have to make some changes to the code to make it work with
your data.
This macro has to go in the sheet module of the sheet that holds the
data. Click on the sheet tab, select View Code, and paste this macro into
the displayed module. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Or Target = "" Then Exit Sub
If Target.Column = 4 And Target.Row1 Then
Application.EnableEvents = False
Target.Offset(, -3).Resize(, 4).Copy
Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Target.EntireRow.Delete
Range("A1").Select
Application.EnableEvents = True
End If
End Sub

BobH" wrote in message
...
What I have is a place in a spreadsheet for people to put
in action items and a complete date (I know, there are
much better tools for this, but this is the tool they want
to use). If there is a completion date (i.e. it isn't
blank) then I want to move that entry down to a separate
section containing completed actions.

My thought was to write a macro that checked each cell for
a completed date and if it contained an entry to simply
cut and paste it onto the end of the list at the bottom.

Thanks for your help.

Bob






-----Original Message-----
Hi,

I want to run a macro that simply moves data from one row
to an area of the worksheet that keeps track of completed
items. What I need is a statement that does something
like this:

=IF(b1="",do nothing, run move macro).

How do I tell the =IF function to run the macro? This
seems to be a pretty easy thing to go yet the Help does
not address it.

Thanks,

Bob
.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Syntax for running a macro from an =IF function?

Thank you Otto. I am very new to Excel programming. I
used to be quite a 123 macro writer but this stuff is not
macro writing any more, it is real programming. Just
writing something that moves four cells to the left and
deletes something is a big deal. I'm learning and greatly
appreciate your help.

Bob



-----Original Message-----
Bob
Here is an event macro that reacts when an entry is

made in column D.
The macro copies Columns A:D of that row and pastes it to

the bottom of the
data range in Column A. It then deletes the row of the

original entry.
You will probably have to make some changes to the code

to make it work with
your data.
This macro has to go in the sheet module of the sheet

that holds the
data. Click on the sheet tab, select View Code, and

paste this macro into
the displayed module. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Or Target = "" Then Exit Sub
If Target.Column = 4 And Target.Row1 Then
Application.EnableEvents = False
Target.Offset(, -3).Resize(, 4).Copy
Range("A" & Rows.Count).End(xlUp).Offset

(1).PasteSpecial
Target.EntireRow.Delete
Range("A1").Select
Application.EnableEvents = True
End If
End Sub

BobH" wrote in

message
...
What I have is a place in a spreadsheet for people to

put
in action items and a complete date (I know, there are
much better tools for this, but this is the tool they

want
to use). If there is a completion date (i.e. it isn't
blank) then I want to move that entry down to a separate
section containing completed actions.

My thought was to write a macro that checked each cell

for
a completed date and if it contained an entry to simply
cut and paste it onto the end of the list at the bottom.

Thanks for your help.

Bob






-----Original Message-----
Hi,

I want to run a macro that simply moves data from one

row
to an area of the worksheet that keeps track of

completed
items. What I need is a statement that does something
like this:

=IF(b1="",do nothing, run move macro).

How do I tell the =IF function to run the macro? This
seems to be a pretty easy thing to go yet the Help does
not address it.

Thanks,

Bob
.



.

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
Running a Macro from a Spreadsheet Function Patrick (GVC) Excel Worksheet Functions 2 February 10th 08 12:30 PM
COUNTA function causing syntax error in macro... Birmangirl Excel Worksheet Functions 4 February 6th 07 04:04 PM
Running a Macro that enters a function that returns #VALUE! gevew Excel Discussion (Misc queries) 3 December 29th 06 08:34 PM
How can I invoke running a macro from within an "IF" function. ron Excel Worksheet Functions 11 February 8th 06 03:35 PM
Macro syntax error when running query rrmando Excel Programming 0 July 26th 04 10:42 PM


All times are GMT +1. The time now is 08:36 PM.

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"