macro in function

duckfoot

New Member
Joined
Apr 21, 2002
Messages
22
Is it possible to run a macro as the result of an IF function?

i.e.
IF(logical_test,value_if_true,RUN MACRO1)

thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
On 2002-05-01 04:35, duckfoot wrote:
Is it possible to run a macro as the result of an IF function?

i.e.
IF(logical_test,value_if_true,RUN MACRO1)

thanks

If you have created a UDF(User Defined Function) then yes.

It does not matter that Excel Already has this function just create a unique name

eg
Function My_If(Cells or Ranges to do test on)

If TestTrue then Call Macro1

End Function

If this is not specific enough Give me some more info.
 
Upvote 0
i'm not entirely sure what you mean so i'll give you some more detail if thats ok:

this is the simple formula i'm using and the macro, when run, simply draws a thick line under several cells.

=IF(RC[1]="",RC[1],macro1)
 
Upvote 0
in fact, that makes no sense to me whatsoever...

i don't know how to use a UDF and really need to know how i "call macro1"
or how i write: "run macro1" in the function.
 
Upvote 0
It sounds like Conditional Formating may be what your looking for...

Select the 1st cell for the Test

Lets say it is Cell C3

Format/Conditional Formatting

In the first drop down change to show Formula is

In the next box enter

=isblank(C3)

Next click the format box and choose underline (This does not stand out so well as you cannot add think...you could also add a Gold background at the same time)
Click OK

Copy the formats to all the cells that you want testing. If the cell is Blank you will see Golden highlighted cells with underline.

Let me know if this does not solve you problem as this is much easier to do than the VB will be(especially if you are not too familiar with it).
 
Upvote 0
ok ok... i've tried that and its not really working.
Imagine i have column A filled irregularly with values and with blank cells inbetween these. I need a thick line passing along the top of only the filled cells and across to column E.
I need to do this rapidly down the column for several thousand rows.
Really appreciate you taking the time to help
Thanks!
 
Upvote 0
On 2002-05-01 05:31, duckfoot wrote:
ok ok... i've tried that and its not really working.
Imagine i have column A filled irregularly with values and with blank cells inbetween these. I need a thick line passing along the top of only the filled cells and across to column E.
I need to do this rapidly down the column for several thousand rows.
Really appreciate you taking the time to help
Thanks!

Can I try one more go at the conditional formatting as It will be much faster for you.

Select Columns A-E
Enter Conditional Formatting
In the box do formula is

=ISBLANK($A1)

Set formatting to Black line (And Gold? as it won't do a thick line)

Click OK.

This will give you instantly the whole spreadsheet highlighted in rows A-E where column A is blank.

If this still doesn't help let me know.

I should really be getting on with my day job soon though so I will give you the code tonight.
 
Upvote 0
OK I have now got the macros working.

I will use the change events...Drop me your email by Private message if you prefer and I'll send it out. (it will take 2-3) hours from now before I get to my home email though...

Anyone else interested drop me a line

If too many I'll post it on the web.
 
Upvote 0
As promised... I have returned with the solution.

This link takes you to the file which you should save to your hard disk and then open from Excel directly...It will not perform correctly from the Web Page view of Excel.

<font color="blue">S-O-S File to underline blanks</font color="blue">

<MARQUEE/>Hope This Helps :wink:</MARQUEE>
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top