A real quickie!

J

JamesBurrows

Is there a way of Setting an If loop to search for A-Z without doing
or B or C or D etc.

I have a column of data and it contains varying things in the specifi
colum but im trying to pick out only those that have a single letter i
them.

Heres my code below is there an operator i can put instead of ????????

If Worksheets("Line List").Cells(i, "B") = ("A"??????????"Z") Then

Cheers

Jame
 
D

Don Guillett

a bit of clarification. Do you mean if A is the FIRST letter? If so,
Sub ifAincell()
For i = 1 To Cells(Rows.Count, "b").End(xlUp).Row
If UCase(Left(Cells(i, "b"), 1)) = "A" Then MsgBox Cells(i, "b")
Next i
End Sub

However, FINDNEXT (look in vba help index for an excellent example) is
better.
--
Don Guillett
SalesAid Software
[email protected]
"JamesBurrows" <[email protected]>
wrote in message
news:[email protected]...
 
J

JamesBurrows

Sorry I will try to clarify this.

I have a colum which may look something like this

A
{blank cell}
B
{blank cell}
Today is the Day
{blank cell}
{blank cell}
A
{blank cell}
|I woke up this morning
D

and I want the If loop to be able to say if = (A-Z) IE if it finds
cell with a single letter in it ie A to Z then......

Hope this help
 
J

JamesBurrows

Sorry I will try to clarify this.

I have a colum which may look something like this

A
{blank cell}
B
{blank cell}
Today is the Day
{blank cell}
{blank cell}
A
{blank cell}
|I woke up this morning
D

and I want the If loop to be able to say if = (A-Z) IE if it finds
cell with a single letter in it ie A to Z then......

Hope this help
 
P

Pete_UK

Try something like this, assuming you are using column A for your
entries:

=IF(LEN(A1)=1,IF(AND(CODE(UPPER(A1))>64,CODE(UPPER(A1))<91),"condition
met",""),"")

adapt the "condition met" message to suit what it is you want to do.
This will check for A to Z and a to z in A1 - remove the UPPER( ) from
the formula to only allow A to Z.

Hope this helps.

Pete
 
D

Don Guillett

Sub insertifnotblank()
For i = Cells(Rows.Count, "b").End(xlUp).Row To 2 Step -1
'If Len(Cells(i, "a")) > 1 Then Rows(i).Insert
If Len(Cells(i, "b")) = 1 And Cells(i, "b") <> " " Then rows(i).insert
Next i
End Sub


--
Don Guillett
SalesAid Software
[email protected]
"JamesBurrows" <[email protected]>
wrote in message
news:[email protected]...
 
Top