Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default custom validation off workbooksheet_change

I have a worksheet_change macro to place the date and time in adjacent cells of the target column(which is the "B" column). I now want to put a custom validation in the "F" column of the same row. How can I work off the target to make the formula dynamic?
The custom validation formula is: =and(len(F3)=8,isnumber(value(left(f3,6))),right(f 3,2)="P6"
I've tried to replace the "F" address's with something like:
len(target.address.offset(0,4)=8
and
I've tried making the "f" cell the active cell and using:
len(activeCell)=8
Both failures
Any help out there?
Thanks
Steve

EggHeadCafe - Software Developer Portal of Choice
Slipstreaming and Unattended Windows Media Creation
http://www.eggheadcafe.com/tutorials...d-unatten.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default custom validation off workbooksheet_change

Hi Steve

This should give you the correct formula:

MyFormula= _
"=And(Len(F" & Target.Row & ")=8,IsNumber(Value(Left(F" & Target.Row &
",6))),Right(F" & Target.Row & ",2)=""" & "P6""" & ")"

Regards,
Per

"Steve Roach" skrev i meddelelsen
...
I have a worksheet_change macro to place the date and time in adjacent
cells of the target column(which is the "B" column). I now want to put a
custom validation in the "F" column of the same row. How can I work off the
target to make the formula dynamic?
The custom validation formula is:
=and(len(F3)=8,isnumber(value(left(f3,6))),right(f 3,2)="P6"
I've tried to replace the "F" address's with something like:
len(target.address.offset(0,4)=8
and
I've tried making the "f" cell the active cell and using:
len(activeCell)=8
Both failures
Any help out there?
Thanks
Steve

EggHeadCafe - Software Developer Portal of Choice
Slipstreaming and Unattended Windows Media Creation
http://www.eggheadcafe.com/tutorials...d-unatten.aspx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Per, I'm not sure what your telling me ?

Thanks for taking the time to reply. Could you expand on your solution a bit more.



Per Jessen wrote:

Hi SteveThis should give you the correct formula:MyFormula= _"=And(Len(F" &
14-Oct-09

Hi Steve

This should give you the correct formula:

MyFormula= _
"=And(Len(F" & Target.Row & ")=8,IsNumber(Value(Left(F" & Target.Row &
",6))),Right(F" & Target.Row & ",2)=""" & "P6""" & ")"

Regards,
Per

"Steve Roach" skrev i meddelelsen

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
ASP.NET Distributed Data Applications
http://www.eggheadcafe.com/tutorials...uted-data.aspx
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Per, I'm not sure what your telling me ?

Steve,

MyFormula is the formula string to be inserted in the custom validation. I
always use a variable to build formula strings, then you can use Debug.Print
MyFormula to print the formula string to the Immediate window. Now I can
verify that my formula is build as I expected...

See my example:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyFormula As String
MyFormula = _
"=And(Len(F" & Target.Row & ")=8,IsNumber(Value(Left(F" & Target.Row _
& ",6))),Right(F" & Target.Row & ",2)=""" & "P6""" & ")"
Debug.Print MyFormula 'just for illustration
If Target.Column = 2 Then
Application.EnableEvents = False
Target.Offset(0, 1) = Now()
With Target.Offset(0, 4).Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:=MyFormula
End With
Application.EnableEvents = True
End If
End Sub

Hopes this helps.
....
Per


"Steve Roach" skrev i meddelelsen
...
Thanks for taking the time to reply. Could you expand on your solution a
bit more.



Per Jessen wrote:

Hi SteveThis should give you the correct formula:MyFormula= _"=And(Len(F"
&
14-Oct-09

Hi Steve

This should give you the correct formula:

MyFormula= _
"=And(Len(F" & Target.Row & ")=8,IsNumber(Value(Left(F" & Target.Row &
",6))),Right(F" & Target.Row & ",2)=""" & "P6""" & ")"

Regards,
Per

"Steve Roach" skrev i meddelelsen

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
ASP.NET Distributed Data Applications
http://www.eggheadcafe.com/tutorials...uted-data.aspx


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
custom data validation on cells with data validation values AKrobbins Excel Worksheet Functions 2 June 21st 11 04:20 PM
custom validation SYBS Excel Worksheet Functions 0 June 16th 06 10:19 AM
Custom Validation Mark McDonough Excel Discussion (Misc queries) 3 May 26th 06 02:41 PM
Using custom functions within custom validation Neil Excel Discussion (Misc queries) 4 December 14th 05 10:40 PM
Custom Validation kalz Excel Worksheet Functions 1 January 26th 05 04:19 AM


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