Using an if-then statement to search for individual characters in a column of cells

DLAhr

New Member
Joined
Jan 28, 2014
Messages
4
GLYTGenlyte Group Inc.4◄4◄2/4/2005$86.98$90.042/11/20053.52%
SGTLSigmatel, Inc.€◄1/14/2005$36.40$40.012/11/20059.92%
LDISLeadis Technology, Inc.∩⌂1/14/2005$7.52$6.812/11/2005-9.39%
CEDCCentral European DistrACAC1/28/2005$32.37$33.852/11/20054.57%
SWFTSwift Transportation ACHS©ACH©1/7/2005$33.53$42.592/11/200527.02%
HUBGHub Group, Inc.GQGNQ1/7/2005$31.87$32.333/22/2005-45.66%
WRLDWorld Acceptance CoABCGX7ABCG71/7/2005$35.43$35.283/22/2005-30.10%
RSTIRofin-Sinar TechGQG1/7/2005$67.56$65.813/22/2005-25.01%
SPFStandard Pacific Corp.RSX771/7/2005$14.41$12.533/22/2005-33.56%
CIGCompanhia Energetica Y2JY1/11/2013$9.62$8.001/3/2014-16.87%
ALVAutoliv Inc.DM226/28/2013$77.39$89.731/3/201415.95%
CRRCCourier CorporationO¿¿11/29/2013$18.72$17.811/3/2014-4.86%
SMCISuper Micro Computer12/6/2013$16.92$16.711/3/2014-1.24%
AHLAspen Insurance HoldDEMD12/6/2013$40.83$40.541/3/2014-0.71%
TEXTerex Corporation¥€«¥€«12/27/2013$41.63$41.281/3/2014-0.84%
CBPOChina Biologic Products JUS5/24/2013$26.52$28.111/3/20146.00%
SNTSSantarus, Inc.€◄HL€7/12/2013$25.57$31.961/3/201424.99%

<tbody>
</tbody>

Range("C3").Select
For combo = 0 To counter

If ActiveCell.Offset(combo, 0).Value = "MQ" Then
Range(ActiveCell.Offset(combo, -2), ActiveCell.Offset(combo, 6)).Select
Selection.Copy

In the "If-Then" statement, I would like to be able to pick out any combination of 2 characters in the sample data set - not just "MQ" which I used as an illustration. For example, I might want to choose the combination "D" & "M", or "A" & "C", or any other combination of two characters.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I found my own simple answer by using the LIKE operator instead of = in the IF statement above which allows me to use wildcard characters. So a new working statement is --> If ActiveCell.Offset(combo, 0).Value Like "D*M" Then
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top