Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Something wrong in one line of VBA code

I copied a procedure from a Walkenbach module that pulls data from Access and
puts it into Excel - it works fine.

But I wanted to adapt it so that pulls a specific company that the user
enters. As they may not enter the exact correct name, I wanted to use the
"Like" facility.

This is the piece I copied from the final line of SQL code I took from Access
HAVING (((Master_Deal.Parent) Like "*Exxon*"));

And I adapted it to Excel VBA form with a variable:
src = src & "HAVING (((Master_Deal.Parent) Like '*" & myCompany & "*'));"

In Access I get give lines returned, in Excel, nothing. Am I correctly
using the LIKE function in Excel VBA?

Hope this is clear, and thanks for any help.

Daniel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Something wrong in one line of VBA code

Thanks Gary, but unfortunately not - it still returns zero records.
I haven't had problems with the apostrophe itself, for example if I put the
exact name in:
src = src & "HAVING (((Master_Deal.Parent) = 'Exxon Ltd'));"
then it returns records.

It's the "LIKE" function that's killing me!

Thanks for replying though.

Daniel


"Gary L Brown" wrote:

Try ...
src = src & "HAVING (((Master_Deal.Parent) Like " & chr(34) & "*" &
myCompany & "*" & chr(34)));"
I haven't tried this.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

I copied a procedure from a Walkenbach module that pulls data from Access and
puts it into Excel - it works fine.

But I wanted to adapt it so that pulls a specific company that the user
enters. As they may not enter the exact correct name, I wanted to use the
"Like" facility.

This is the piece I copied from the final line of SQL code I took from Access
HAVING (((Master_Deal.Parent) Like "*Exxon*"));

And I adapted it to Excel VBA form with a variable:
src = src & "HAVING (((Master_Deal.Parent) Like '*" & myCompany & "*'));"

In Access I get give lines returned, in Excel, nothing. Am I correctly
using the LIKE function in Excel VBA?

Hope this is clear, and thanks for any help.

Daniel



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Something wrong in one line of VBA code

Try changing the * wildcard with the % wildcard.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

Thanks Gary, but unfortunately not - it still returns zero records.
I haven't had problems with the apostrophe itself, for example if I put the
exact name in:
src = src & "HAVING (((Master_Deal.Parent) = 'Exxon Ltd'));"
then it returns records.

It's the "LIKE" function that's killing me!

Thanks for replying though.

Daniel


"Gary L Brown" wrote:

Try ...
src = src & "HAVING (((Master_Deal.Parent) Like " & chr(34) & "*" &
myCompany & "*" & chr(34)));"
I haven't tried this.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

I copied a procedure from a Walkenbach module that pulls data from Access and
puts it into Excel - it works fine.

But I wanted to adapt it so that pulls a specific company that the user
enters. As they may not enter the exact correct name, I wanted to use the
"Like" facility.

This is the piece I copied from the final line of SQL code I took from Access
HAVING (((Master_Deal.Parent) Like "*Exxon*"));

And I adapted it to Excel VBA form with a variable:
src = src & "HAVING (((Master_Deal.Parent) Like '*" & myCompany & "*'));"

In Access I get give lines returned, in Excel, nothing. Am I correctly
using the LIKE function in Excel VBA?

Hope this is clear, and thanks for any help.

Daniel



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Something wrong in one line of VBA code

Try replacing the * wildcard with the % wildcard.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

Thanks Gary, but unfortunately not - it still returns zero records.
I haven't had problems with the apostrophe itself, for example if I put the
exact name in:
src = src & "HAVING (((Master_Deal.Parent) = 'Exxon Ltd'));"
then it returns records.

It's the "LIKE" function that's killing me!

Thanks for replying though.

Daniel


"Gary L Brown" wrote:

Try ...
src = src & "HAVING (((Master_Deal.Parent) Like " & chr(34) & "*" &
myCompany & "*" & chr(34)));"
I haven't tried this.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

I copied a procedure from a Walkenbach module that pulls data from Access and
puts it into Excel - it works fine.

But I wanted to adapt it so that pulls a specific company that the user
enters. As they may not enter the exact correct name, I wanted to use the
"Like" facility.

This is the piece I copied from the final line of SQL code I took from Access
HAVING (((Master_Deal.Parent) Like "*Exxon*"));

And I adapted it to Excel VBA form with a variable:
src = src & "HAVING (((Master_Deal.Parent) Like '*" & myCompany & "*'));"

In Access I get give lines returned, in Excel, nothing. Am I correctly
using the LIKE function in Excel VBA?

Hope this is clear, and thanks for any help.

Daniel





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Something wrong in one line of VBA code


You could also use the built in function:

StrConv(<string name, <number) Where this would take care of
lower/uppercase problems. For number, 1 is lower, 2 upper, 3 'proper'
(joe blow becomes Joe Blow)


--
McManCSU
------------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379
View this thread: http://www.excelforum.com/showthread...hreadid=382627

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Something wrong in one line of VBA code

You're a genius!! Thanks so much.

"Gary L Brown" wrote:

Try replacing the * wildcard with the % wildcard.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

Thanks Gary, but unfortunately not - it still returns zero records.
I haven't had problems with the apostrophe itself, for example if I put the
exact name in:
src = src & "HAVING (((Master_Deal.Parent) = 'Exxon Ltd'));"
then it returns records.

It's the "LIKE" function that's killing me!

Thanks for replying though.

Daniel


"Gary L Brown" wrote:

Try ...
src = src & "HAVING (((Master_Deal.Parent) Like " & chr(34) & "*" &
myCompany & "*" & chr(34)));"
I haven't tried this.
HTH,
--
Gary Brown

If this post was helpful, please click the ''''''''Yes'''''''' button next
to ''''''''''''''''Was this Post Helpfull to you?".


"Daniel Bonallack" wrote:

I copied a procedure from a Walkenbach module that pulls data from Access and
puts it into Excel - it works fine.

But I wanted to adapt it so that pulls a specific company that the user
enters. As they may not enter the exact correct name, I wanted to use the
"Like" facility.

This is the piece I copied from the final line of SQL code I took from Access
HAVING (((Master_Deal.Parent) Like "*Exxon*"));

And I adapted it to Excel VBA form with a variable:
src = src & "HAVING (((Master_Deal.Parent) Like '*" & myCompany & "*'));"

In Access I get give lines returned, in Excel, nothing. Am I correctly
using the LIKE function in Excel VBA?

Hope this is clear, and thanks for any help.

Daniel



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
Combobox has no arrow, just a line on the right, what's wrong? Tomatoman Excel Worksheet Functions 2 May 7th 10 06:35 PM
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
What is wrong with this line? ChartsToBe Charts and Charting in Excel 0 July 28th 06 12:08 AM
Whats wrong with this line of code? Edgar Thoemmes[_4_] Excel Programming 4 October 26th 04 12:52 PM
What's wrong with this line of code? Sandy[_3_] Excel Programming 0 July 23rd 03 12:15 PM


All times are GMT +1. The time now is 08:11 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"