Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Wildcard in VBA?

I apologize if this is here twice--I don't see the post I thought went
through earlier today. Anyway ..

I have the following code:

If .Cells(X, "H") = "RG" Then
.Cells(X, "G").Value = "TRC"
End If

Can I modify this with a "wildcard" character? In other words, if RG is
found anywhere (RG123, RG456, 123RG, etc) within cell H, I want TRC to be
placed into column G

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Wildcard in VBA?

maybe something like this, i just hard coded the variable for testing

Sub test()
Dim x As Long
x = 3

If Cells(x, "H") Like "?G" Then
Cells(x, "G").Value = "TRC"
End If

End Sub

--


Gary Keramidas
Excel 2003


"richzip" wrote in message
...
I apologize if this is here twice--I don't see the post I thought went
through earlier today. Anyway ..

I have the following code:

If .Cells(X, "H") = "RG" Then
.Cells(X, "G").Value = "TRC"
End If

Can I modify this with a "wildcard" character? In other words, if RG is
found anywhere (RG123, RG456, 123RG, etc) within cell H, I want TRC to be
placed into column G

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Wildcard in VBA?

Given what the OP posted, I believe your Like operator test should be this...

If Cells(x, "H") Like "*RG*" Then

That would be a case sensitive test; if the OP need a non-case sensitive test, that would look like this...

If Cells(x, "H") Like "*[Rr][Gg]*" Then

--
Rick (MVP - Excel)


"Gary Keramidas" <GKeramidasAtMSN.com wrote in message ...
maybe something like this, i just hard coded the variable for testing

Sub test()
Dim x As Long
x = 3

If Cells(x, "H") Like "?G" Then
Cells(x, "G").Value = "TRC"
End If

End Sub

--


Gary Keramidas
Excel 2003


"richzip" wrote in message
...
I apologize if this is here twice--I don't see the post I thought went
through earlier today. Anyway ..

I have the following code:

If .Cells(X, "H") = "RG" Then
.Cells(X, "G").Value = "TRC"
End If

Can I modify this with a "wildcard" character? In other words, if RG is
found anywhere (RG123, RG456, 123RG, etc) within cell H, I want TRC to be
placed into column G

Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Wildcard in VBA?

yea, i missed this part (RG123, RG456, 123RG).
i guess i should read the entire post<g

--


Gary Keramidas
Excel 2003


"Rick Rothstein" wrote in message
...
Given what the OP posted, I believe your Like operator test should be this...

If Cells(x, "H") Like "*RG*" Then

That would be a case sensitive test; if the OP need a non-case sensitive test,
that would look like this...

If Cells(x, "H") Like "*[Rr][Gg]*" Then

--
Rick (MVP - Excel)


"Gary Keramidas" <GKeramidasAtMSN.com wrote in message
...
maybe something like this, i just hard coded the variable for testing

Sub test()
Dim x As Long
x = 3

If Cells(x, "H") Like "?G" Then
Cells(x, "G").Value = "TRC"
End If

End Sub

--


Gary Keramidas
Excel 2003


"richzip" wrote in message
...
I apologize if this is here twice--I don't see the post I thought went
through earlier today. Anyway ..

I have the following code:

If .Cells(X, "H") = "RG" Then
.Cells(X, "G").Value = "TRC"
End If

Can I modify this with a "wildcard" character? In other words, if RG is
found anywhere (RG123, RG456, 123RG, etc) within cell H, I want TRC to be
placed into column G

Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Wildcard in VBA?

Try something like

If InStr(Cells(X, "H").Text, "RG") 0 Then
Cells(X, "G").Value = "TRC"
End If

Steve

"richzip" wrote in message
...
I apologize if this is here twice--I don't see the post I thought went
through earlier today. Anyway ..

I have the following code:

If .Cells(X, "H") = "RG" Then
.Cells(X, "G").Value = "TRC"
End If

Can I modify this with a "wildcard" character? In other words, if RG is
found anywhere (RG123, RG456, 123RG, etc) within cell H, I want TRC to be
placed into column G

Thanks!




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
Trying to CF using a wildcard toonarme Excel Discussion (Misc queries) 3 July 18th 10 10:52 PM
Using OR and wildcard Tendresse Excel Programming 1 March 19th 08 10:09 AM
Wildcard in SUM Dean Excel Programming 8 July 26th 07 05:02 PM
wildcard JOUIOUI Excel Programming 5 July 31st 06 01:47 PM
Wildcard fugfug[_10_] Excel Programming 0 July 14th 05 12:34 PM


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