Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Hi there,
I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Hi
if left(activecell.value,1)="P" then ..... -- Regards Frank Kabel Frankfurt, Germany schrieb im Newsbeitrag oups.com... Hi there, I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Hi Michael,
I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? Are you writing a VBA user-defined function (UDF), or are you looking for a worksheet function solution? If you want to use worksheet functions: =IF(LEFT(A1,1)="p", "yes", "no") If VBA: If UCase$(Left$(ActiveCell.Value, 1)) = "P" Then MsgBox "yes" Else MsgBox "no" End If The worksheet example isn't case sensitive. If you want only capital P's to be matched, remove the UCase$() from the second example. -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Perhaps something like this?
Sub StartingwithP() If Left(Selection.Value, 1) = "p" Then MsgBox "woohoo" End If End Sub tj " wrote: Hi there, I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
wrote in message oups.com... Hi there, I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? If Left(ActiveCell.Value,1) = "P" Then Do Something End If -gk- |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Mine should be ActiveCell.Value, like the other answers posted.
tj "tjtjjtjt" wrote: Perhaps something like this? Sub StartingwithP() If Left(Selection.Value, 1) = "p" Then MsgBox "woohoo" End If End Sub tj " wrote: Hi there, I am writing a function that needs to have a statement in it that goes If [data in ActiveCell] begins with "P" then do something. How do I do this? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Alternative, purely for the sake of diversity ...
If ActiveCell.Value Like "[Aa]*" Then Do Something End If Oh, and I like the "Like" operator ;o) | If Left(ActiveCell.Value,1) = "P" Then | Do Something | End If |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you say "begins with"
Alternative, purely for the sake of diversity ...
If ActiveCell.Value Like "[Aa]*" Then Do Something End If Oh, and I like the "Like" operator ;o) | If Left(ActiveCell.Value,1) = "P" Then | Do Something | End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
How do I write "begins with"? | Excel Discussion (Misc queries) | |||
Sorting text that begins with "the" or "a" | Excel Discussion (Misc queries) | |||
highest value in a Row, that begins with "21" or "28" | Excel Programming |