Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calling a function within a macro

Hi,

I have a worksheet called SDB which consists of a row (1) of column headings
and then a row (2) of cell values/references/formulas etc. a second sheet
called Data in the same workbook holds data values from another source which
need to be organised/formatted in a diferent way (i.e. this is what the SDB
sheet does). My macro called SDB_copy selects row 2 of SDB and copies down to
the last lastrow of data (the lastrow is found using the following line of
code: lastrow = Sheets("Data").Cells(Cells.Rows.Count, "A").End(xlUp).row)

SDB has some cells which are conditionally formatted to have a red
background on certain conditions. I have a couple of functions that 1.
identify the colour index (CFColorindex) and 2. count the number of cells
which have the specified condition (CFColorCount).

I can call the functions from a cell in the worksheet using:
=CFColorCount(Z2:Z76,3)
which gives the right answer.

What I want to do is call the function from my SDB_copy macro and display
the result in a message box, for example

MsgBox("Please correct errors -" answer)

So far I have tried various ways of calling the function from within my
macro, such as:

Dim Res As Variant
Res = Application.Function.CFColorCount("Z2:Z76", 3)
MsgBox ("Please Rectify All Highlighted Records - " & Res)

but when I try to run the macro I get an error suggesting that the : in the
range is unexpected.

I would also like to be able to use the lastrow facility such that the range
to be counted is ("A2:A" & lastrow).

I know this is probably really simple but I just cant get the coding right,
all help is gratefully received!

I apologise if my explanation is a bit long, thanks in advance
Kind regards,
Amy
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
Calling Function in Add-in MikeH2 Excel Programming 4 February 25th 08 09:36 PM
Calling VBA Function João Excel Programming 1 March 18th 07 04:34 AM
calling worksheet function from a macro Joe Farruggio Excel Worksheet Functions 3 November 20th 06 10:01 PM
Calling an Excel function from a VBA macro Steven M (remove wax and invalid to reply) Excel Programming 3 January 19th 06 11:01 AM
Calling up the Solver function in a VBA macro Ken Wright Excel Programming 3 January 28th 04 04:21 PM


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