#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA Wildcard Code

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA Wildcard Code

If Left(wsMaster.Range("ag" & iRow + 0),1) = "c" Then
--
Gary''s Student - gsnu200853


"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default VBA Wildcard Code

Try instr

If InStr(Sheets(wsMaster).Range("ag" & irow + 0), "c") = 1 Then

Mike

"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default VBA Wildcard Code

I just noticed you may want it to ignore case

If InStr(1, Sheets(wsMaster).Range("ag" & irow + 0), "c", 1) = 1 Then

Mike

"Mike H" wrote:

Try instr

If InStr(Sheets(wsMaster).Range("ag" & irow + 0), "c") = 1 Then

Mike

"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA Wildcard Code

Gary, even though I checked the running of the code and verified that the
cell contents does contain a Cxx value after reading each record, it bypasses
the record
and moves on the to the next record with the final outcome being no records
written.

Any suggestions?

Tony

"Gary''s Student" wrote:

If Left(wsMaster.Range("ag" & iRow + 0),1) = "c" Then
--
Gary''s Student - gsnu200853


"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA Wildcard Code

Mike, when I use your code, I get a Run-time error '13' - Type mismatch error.

"Mike H" wrote:

I just noticed you may want it to ignore case

If InStr(1, Sheets(wsMaster).Range("ag" & irow + 0), "c", 1) = 1 Then

Mike

"Mike H" wrote:

Try instr

If InStr(Sheets(wsMaster).Range("ag" & irow + 0), "c") = 1 Then

Mike

"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VBA Wildcard Code

One more using a wildcard:

if lcase(wsmaster.range("ag" & irow).value) like lcase("c*") then




Tony wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.

If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA Wildcard Code

Try both "c" and "C"
--
Gary''s Student - gsnu200853


"Tony" wrote:

Gary, even though I checked the running of the code and verified that the
cell contents does contain a Cxx value after reading each record, it bypasses
the record
and moves on the to the next record with the final outcome being no records
written.

Any suggestions?

Tony

"Gary''s Student" wrote:

If Left(wsMaster.Range("ag" & iRow + 0),1) = "c" Then
--
Gary''s Student - gsnu200853


"Tony" wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.


If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA Wildcard Code

Thanks again Dave, that did the trick.

"Dave Peterson" wrote:

One more using a wildcard:

if lcase(wsmaster.range("ag" & irow).value) like lcase("c*") then




Tony wrote:

I have the following could that checks a column in a master file to select
records that have the following c* (i.e. c01, c02, etc..). However due to
some error in the way I am writing the code, I cannot get it to produce
records.

If wsMaster.Range("ag" & iRow + 0) = "c* " Then

How do I code it the slect any records that start with "C" and then use the
wildcard character "*"?


--

Dave Peterson

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
Using the wildcard with IF DamienO New Users to Excel 5 January 29th 09 01:51 AM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
If and wildcard Fish Excel Discussion (Misc queries) 3 October 1st 08 01:33 AM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
sum if wildcard Marcel New Users to Excel 1 April 30th 06 11:25 AM


All times are GMT +1. The time now is 10:42 PM.

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"