Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA function to return letters of alphabet

Hi All,

I'd be grateful for some help please. I'm looking for a VBA functio
that will return each letter of the alphabet in turn.

I have a query that brings me back all the people in my list whos
surname begins with the letter "A". I know I could run this query 2
times (to return surnames for each letter) but I'd like to be able t
run it with the result of the function passed as a paramater so that
could end up with a table of all my names. The reason I have to spli
it up 26 times is that the query is so big that it falls over if I as
for all names at once.

Hope that makes sense

TIA

Seamu

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default VBA function to return letters of alphabet

Hi
have a look at the Chr function in the VBA helpt. Combine this with a
For next loop

--
Regards
Frank Kabel
Frankfurt, Germany


Hi All,

I'd be grateful for some help please. I'm looking for a VBA function
that will return each letter of the alphabet in turn.

I have a query that brings me back all the people in my list whose
surname begins with the letter "A". I know I could run this query 26
times (to return surnames for each letter) but I'd like to be able to
run it with the result of the function passed as a paramater so that

I
could end up with a table of all my names. The reason I have to

split
it up 26 times is that the query is so big that it falls over if I

ask
for all names at once.

Hope that makes sense

TIA

Seamus


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA function to return letters of alphabet

Seamus,

Here is a simple function

Dim iLetter As Long

Function NextLetter() As String
If Val(iLetter) = 0 Then
iLetter = 65
Else
iLetter = iLetter + 1
End If
NextLetter = Chr(iLetter)
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"SOS " wrote in message
...
Hi All,

I'd be grateful for some help please. I'm looking for a VBA function
that will return each letter of the alphabet in turn.

I have a query that brings me back all the people in my list whose
surname begins with the letter "A". I know I could run this query 26
times (to return surnames for each letter) but I'd like to be able to
run it with the result of the function passed as a paramater so that I
could end up with a table of all my names. The reason I have to split
it up 26 times is that the query is so big that it falls over if I ask
for all names at once.

Hope that makes sense

TIA

Seamus


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA function to return letters of alphabet

Thanks to both Bob and Frank - I will work away with this informatio
and hope that I can incorporate the variable into my SQL statement.

Thanks again

Seamu

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA function to return letters of alphabet

Seamus,

Try a loop structure like the following:

Dim FirstLetter As String
Dim Ndx As Integer
For Ndx = 65 To 90 ' upper case letters
FirstLetter = Chr(Ndx)
' do you query using FirstLetter
Next Ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"SOS " wrote in message
...
Hi All,

I'd be grateful for some help please. I'm looking for a VBA

function
that will return each letter of the alphabet in turn.

I have a query that brings me back all the people in my list

whose
surname begins with the letter "A". I know I could run this

query 26
times (to return surnames for each letter) but I'd like to be

able to
run it with the result of the function passed as a paramater so

that I
could end up with a table of all my names. The reason I have

to split
it up 26 times is that the query is so big that it falls over

if I ask
for all names at once.

Hope that makes sense

TIA

Seamus


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA function to return letters of alphabet

Thanks for the help. Admittedly the work I'm doing is in Access but th
VBA rules apply. I have now got my userform working having adopted th
loop and have my queries running using SQL. I feel quite proud o
myself (IMHO)(LOL)

Thanks again - you guys always come through

Seamu

--
Message posted from http://www.ExcelForum.com

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
how do I increment letters of the alphabet for a database gretchen Excel Discussion (Misc queries) 5 August 30th 07 09:10 PM
Solver - Assign values to the letters of the alphabet [email protected] Excel Discussion (Misc queries) 2 December 15th 06 11:18 AM
Solver - Assign values to Letters of the Alphabet GeoJack Excel Discussion (Misc queries) 0 December 14th 06 06:25 AM
associate alphabet letters with numbers? Loriandme69 New Users to Excel 4 November 22nd 05 01:59 AM
how to assign a value to the alphabet in order to add up letters Robert Horne Excel Discussion (Misc queries) 1 December 10th 04 08:15 PM


All times are GMT +1. The time now is 06:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"