Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Finding Column Letters

On opening a form, 6 txtboxes are populated with column letters IF a field
name is found in data with a variable number of columns and field names in
varying order.

This code seemed to work fine but not always
Sub FindCols()
On Error Resume Next
txtFax.Text = Split(Rows(1).Find("Fax").Address, "$")(1)
txtSalut.Text = Split(Rows(1).Find("Salutation").Address, "$")(1)
txtFirstName.Text = Split(Rows(1).Find("FirstName").Address, "$")(1)
txtLastName.Text = Split(Rows(1).Find("LastName").Address, "$")(1)
txtJob.Text = Split(Rows(1).Find("Job").Address, "$")(1)
txtCompany.Text = Split(Rows(1).Find("Company").Address, "$")(1)
On Error GoTo 0
End Sub

yields:
txtFax = AB
txtSalut = ""
txtFirstName = ""
txtLastName = M
txtJob = A
txtCompany = CA

with this data
A M AB CA
Job LastName Fax Company

but with this data
A C M AB CA
Job Christian Name LastName Fax Company

yields:
txtFax = AB
txtSalut = ""
txtFirstName = ""
txtLastName = M
txtJob = A
txtCompany = C NOT CA ***********************

Find appears to search for capitals and not whole words?
How should my code be amended to make this work?

Geoff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Finding Column Letters

So sorryyyyyyyy to waste time.
The code does work correctly. In testing I had failed to remove the
previous results from the txtboxes and the rest was sheer coincidence.
dohhh, shame:(

Geoff

"Geoff" wrote:

On opening a form, 6 txtboxes are populated with column letters IF a field
name is found in data with a variable number of columns and field names in
varying order.

This code seemed to work fine but not always
Sub FindCols()
On Error Resume Next
txtFax.Text = Split(Rows(1).Find("Fax").Address, "$")(1)
txtSalut.Text = Split(Rows(1).Find("Salutation").Address, "$")(1)
txtFirstName.Text = Split(Rows(1).Find("FirstName").Address, "$")(1)
txtLastName.Text = Split(Rows(1).Find("LastName").Address, "$")(1)
txtJob.Text = Split(Rows(1).Find("Job").Address, "$")(1)
txtCompany.Text = Split(Rows(1).Find("Company").Address, "$")(1)
On Error GoTo 0
End Sub

yields:
txtFax = AB
txtSalut = ""
txtFirstName = ""
txtLastName = M
txtJob = A
txtCompany = CA

with this data
A M AB CA
Job LastName Fax Company

but with this data
A C M AB CA
Job Christian Name LastName Fax Company

yields:
txtFax = AB
txtSalut = ""
txtFirstName = ""
txtLastName = M
txtJob = A
txtCompany = C NOT CA ***********************

Find appears to search for capitals and not whole words?
How should my code be amended to make this work?

Geoff

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
Finding 2 different letters in a range Bampah Excel Worksheet Functions 6 October 8th 09 10:20 PM
How do change a column of data in capitol letters to small letters Barb P. Excel Discussion (Misc queries) 6 November 15th 06 06:17 PM
Finding most common occurence of values in cells containing letters and numbers sparklyballs Excel Worksheet Functions 2 August 18th 06 12:16 PM
finding out the combination of letters! via135 Excel Worksheet Functions 2 February 13th 06 05:12 AM
Finding Numbers with Cells that also contain letters Adam Excel Discussion (Misc queries) 7 December 29th 04 02:41 PM


All times are GMT +1. The time now is 10:51 AM.

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

About Us

"It's about Microsoft Excel"