PC Review


Reply
Thread Tools Rate Thread

Adding Sub code in Function module

 
 
wpreqq99@yahoo.com
Guest
Posts: n/a
 
      3rd Apr 2009
When the user types in a Y in column O, the statement below will put
today's date in Column Q. The cells in Column Q have this formula:
=IF(O2="y",dateStamp()," ")

Here's what I have in a module:
Function DateStamp()
DateStamp = Date
End Function

What I would like to do is to add something like this
ActiveCell.Formula = ActiveCell.Value

I want the cell in Column Q to be static after the Y in typed in.
Right now, that value will change each day.

I've tried to add the last line in the Function module, and it doesn't
work. I've tried to have a seperate Sub, but it won't go there from
the Function module.

Any suggestions?
 
Reply With Quote
 
 
 
 
jasontferrell
Guest
Posts: n/a
 
      3rd Apr 2009
I do not think this is possible via a UDF. Functions that are
designed to return a value within a cell (and called from a cell)
cannot also change attributes of that cell, including formatting or
changing the formula of the cell itself.
 
Reply With Quote
 
wpreqq99@yahoo.com
Guest
Posts: n/a
 
      3rd Apr 2009
On Apr 3, 12:22*pm, jasontferrell <jasontferr...@gmail.com> wrote:
> I do not think this is possible via a UDF. *Functions that are
> designed to return a value within a cell (and called from a cell)
> cannot also change attributes of that cell, including formatting or
> changing the formula of the cell itself.


Thanks for replying.
I know there has to be a way to apply a static date stamp in a cell
when a user types something in another cell.
What I'm asking for in this post is another work around I've tried to
come up with this end result.
If anyone has an answer to how to do this, please let me know.

I would appreciate any help.
j.o.
 
Reply With Quote
 
jasontferrell
Guest
Posts: n/a
 
      3rd Apr 2009
Ahhh, try this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("O:O"), Target) Is Nothing Then
If LCase(Target.Value) = "y" Then
Target.Offset(0, 2).Value = Date
End If
End If
End Sub

It needs to go into the code module specific to the sheet on which you
want the functionality. (VBAProject->Microsoft Excel Objects->Sheet1,
for example).
 
Reply With Quote
 
wpreqq99@yahoo.com
Guest
Posts: n/a
 
      6th Apr 2009
On Apr 3, 4:12*pm, jasontferrell <jasontferr...@gmail.com> wrote:
> Ahhh, try this:
> Private Sub Worksheet_Change(ByVal Target As Range)
> * * If Not Intersect(Range("O:O"), Target) Is Nothing Then
> * * * * If LCase(Target.Value) = "y" Then
> * * * * * * Target.Offset(0, 2).Value = Date
> * * * * End If
> * * End If
> End Sub
>
> It needs to go into the code module specific to the sheet on which you
> want the functionality. *(VBAProject->Microsoft Excel Objects->Sheet1,
> for example).


EXCELLENT
This is what I was looking for.
Many thanks
j.o.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Redemption code to Access Module Dave Couch Microsoft Access VBA Modules 1 9th Oct 2009 09:24 PM
adding an update query to my module code DanRoy Microsoft Access VBA Modules 0 5th Jun 2008 09:56 PM
Trouble Adding VBA Code to Module; Bug in Excel/VBE? =?Utf-8?B?TWF0IFA6c29u?= Microsoft Excel Programming 5 20th Apr 2006 07:37 PM
Adding Code to the This_workbook module of a created workbook RPIJG Microsoft Excel Programming 1 9th Jul 2004 06:35 PM
Adding Code Module to Workbook Charles Microsoft Excel Programming 2 6th Jan 2004 08:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:51 AM.