View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mralmackay@aol.com is offline
external usenet poster
 
Posts: 56
Default Query - Formula (Test for string)

Hi,

Can someone help with the following @ all. I've created the following
VBA which works as expected the first time, however I only want it to
check for the value once, whereas this will add in the prefix more
than once when I run it?

e.g. this is meant to check B4, if this contains CD- don't do anything
if it doesn't add it in.

Any suggestions?

Cheers, Al.

Sub Prefix()
Const Prefix = "CD-"

If Left("B4", 3) = "CD-" Then
Range("B4").Select
ActiveCell.Value = Prefix & ActiveCell.Value
Else
End If
End Sub