A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Get current cell with VBA function



 
 
Thread Tools Display Modes
  #1  
Old April 4th 05, 07:01 PM
vbphil
external usenet poster
 
Posts: n/a
Default Get current cell with VBA function

I've written a VBA function that will be used on a worksheet as a worksheet
function. I want to modify the formatting of the cell that the function is
in. I haven't found any way that works. How do you reference the cell that
the formula is in and make changes to it?

Thanks, -phil
--
no place like 127.0.0.1
Ads
  #3  
Old April 4th 05, 07:31 PM
vbphil
external usenet poster
 
Posts: n/a
Default

ActiveCell doesn't compute in a function called from a worksheet formula. It
only works from within a VBA macro call.
  #5  
Old April 4th 05, 08:06 PM
JE McGimpsey
external usenet poster
 
Posts: n/a
Default

Functions, including User Defined Functions, cannot change the
formatting of a cell.

To do that you'd need an event macro in the worksheet or workbook code
module, e.g., Worksheet_Change, or Worksheet_Calculate.

If you post what you're trying to do, it would be easier to suggest a
solution.


In article >,
vbphil > wrote:

> I've written a VBA function that will be used on a worksheet as a worksheet
> function. I want to modify the formatting of the cell that the function is
> in. I haven't found any way that works. How do you reference the cell that
> the formula is in and make changes to it?

  #6  
Old April 4th 05, 11:23 PM
vbphil
external usenet poster
 
Posts: n/a
Default

You have answered the basis of my question. It can't be done this way.
Here's a greatly simplified example. I just wanted to know if you can
access the range object or cell of where the formula is entered besides just
settings it value.

'the worksheet cell formula would be "=setFormat()"

function setFormat() as string
'set the font of this cell to bold or set the color
.......
'set the cell value
setFormat = "test"
end function


Thanks for the feedback, -phi
"JE McGimpsey" wrote:

> Functions, including User Defined Functions, cannot change the
> formatting of a cell.
>
> To do that you'd need an event macro in the worksheet or workbook code
> module, e.g., Worksheet_Change, or Worksheet_Calculate.
>
> If you post what you're trying to do, it would be easier to suggest a
> solution.
>
>
> In article >,
> vbphil > wrote:
>
> > I've written a VBA function that will be used on a worksheet as a worksheet
> > function. I want to modify the formatting of the cell that the function is
> > in. I haven't found any way that works. How do you reference the cell that
> > the formula is in and make changes to it?

>

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i insert the current time into a cell, and show different . Dave Excel Discussion (Misc queries) 1 March 22nd 05 06:57 PM
Current Cell Color mike47338 Excel Worksheet Functions 5 December 10th 04 06:45 PM
Is there a function to determine whether a cell contains a formul. Christo Kriel Excel Worksheet Functions 1 November 20th 04 06:54 PM
Excel - option to extend function in cell to column kjoshua777 Excel Worksheet Functions 2 November 18th 04 01:08 AM
Finding last cell to contain same value as current cell? rcmodelr Excel Worksheet Functions 3 November 10th 04 12:54 PM


All times are GMT +1. The time now is 03:28 PM.


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