ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   A real quickie! (https://www.excelbanter.com/excel-discussion-misc-queries/92609-real-quickie.html)

JamesBurrows

A real quickie!
 

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

I have a column of data and it contains varying things in the specific
colum but im trying to pick out only those that have a single letter in
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

James


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile: http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445


Don Guillett

A real quickie!
 
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

"JamesBurrows"
wrote in message
news:JamesBurrows.2919mm_1149685801.1005@excelforu m-nospam.com...

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

I have a column of data and it contains varying things in the specific
colum but im trying to pick out only those that have a single letter in
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

James


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile:
http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445




JamesBurrows

A real quickie!
 

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 a
cell with a single letter in it ie A to Z then......

Hope this helps


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile: http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445


JamesBurrows

A real quickie!
 

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 a
cell with a single letter in it ie A to Z then......

Hope this helps


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile: http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445


Pete_UK

A real quickie!
 
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

JamesBurrows wrote:
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 a
cell with a single letter in it ie A to Z then......

Hope this helps


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile: http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445



Don Guillett

A real quickie!
 
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

"JamesBurrows"
wrote in message
news:JamesBurrows.291b90_1149687905.9475@excelforu m-nospam.com...

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 a
cell with a single letter in it ie A to Z then......

Hope this helps


--
JamesBurrows
------------------------------------------------------------------------
JamesBurrows's Profile:
http://www.excelforum.com/member.php...o&userid=35101
View this thread: http://www.excelforum.com/showthread...hreadid=549445





All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com