Case insensitive

Jesslynn

New Member
Joined
Jun 16, 2015
Messages
17
Can anybody help me?
Example: I want the word "the"

it must be able to copy any word with "the" inside.
Like, These, tHEsE, ThE, thEresa would be copied.

The code looks like this..

Code:
Sub NonSensitive()




Dim rCell As Range
For iCntr = 1 To 30




    For Each rCell In Range("I1:I10")
   
    
If Cells.Find(what:=Sheets("Sheet1").Cells(iCntr, 9).Value, after:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate Then






    If Cells(iCntr, 9) = Cells(5, 11) Then
        


 Cells(iCntr, 10) = Cells(iCntr, 9)
 
 
 End If
        
End If
'MsgBox rCell.Address & " has " & rCell & " in it"






    Next rCell
    Next iCntr


  
End Sub

The code above only copied the "The" word.
Thanks in advance!
 
Hi, another small question.
May I know what code i could use to paste the results to the next sheet?


Code:
Sheets(Sheet1).Range(1,1).Value = Sheets(Sheet2).Range(1,1)

I used the above code and it copied the entire column A words from sheet 1 into column A in sheet 2.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Jesslynn,

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0
Jesslynn,

Here is another macro solution for you to consider, based on Rick Rothstein's code, that will ask for the word to find, using an InputBox.

Code:
Sub FindWord()
' hiker95, 07/29/2015, ME871409
Dim Addr As String, Word As String
Word = InputBox("Type in the word that you want to find.")
Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
Range(Addr).Offset(, 1) = Evaluate(Replace("IF(ISNUMBER(SEARCH(""" & Word & """,@)),@,"""")", "@", Addr))
End Sub
 
Upvote 0
Hi, another small question.
May I know what code i could use to paste the results to the next sheet?


Code:
Sheets(Sheet1).Range(1,1).Value = Sheets(Sheet2).Range(1,1)

I used the above code and it copied the entire column A words from sheet 1 into column A in sheet 2.

Jesslynn,

Sorry, I missed that request.

So that we can get it right on the first try:

1. Can we have a screenshot of the raw data in Sheet1?

2. And, can we have a screenshot of the results in Sheet2?
 
Upvote 0
These is what I have :)

Sheet 1
Column:

A B C
Bean$2.20 Supermarket
Soy$1.90 Provision
Soya $0.90 7-eleven
SoyaBean$3.20 7-eleven
Soya Bean $3.20 Giant
Sauce $5.60 Giant
Word to find: Soy

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Sheet 2:
Provision Shop $1.90 Soy
7-eleven $0.90 Soya
7-eleven $3.20 SoyaBean
Giant $3.20 Soya Bean

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>


Thank you so much for your time! And sorry for the trouble!
 
Upvote 0
Jesslynn,

Here is another macro solution for you to consider, that also uses the InputBox to ask for the word to search for, and, uses two arrays in memory to process the raw data, and, results.

I assume that worksheets Sheet1, and, Sheet2, already exist.

In this example the word that is entered into the InputBox is soy.

Sample raw data worksheet Sheet1:


Excel 2007
ABC
1Bean$2.20Supermarket
2Soy$1.90Provision Shop
3Soya$0.907-eleven
4SoyaBean$3.207-eleven
5Soya Bean$3.20Giant
6Sauce$5.60Giant
7
Sheet1


After the macro in worksheet Sheet2:


Excel 2007
ABC
1Provision Shop$1.90Soy
27-eleven$0.90Soya
37-eleven$3.20SoyaBean
4Giant$3.20Soya Bean
5
Sheet2


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Option Compare Text
Sub FindWord_V2()
' hiker95, 07/29/2015, ME871409
Dim a As Variant, o As Variant
Dim i As Long, j As Long
Dim Word As String
Word = InputBox("Type in the word that you want to find.")
Application.ScreenUpdating = False
With Sheets("Sheet1")
  a = .Range("A1:C" & .Cells(Rows.Count, "A").End(xlUp).Row)
  ReDim o(1 To UBound(a, 1), 1 To UBound(a, 2))
End With
For i = 1 To UBound(a, 1)
  If InStr(a(i, 1), Word) Then
    j = j + 1: o(j, 1) = a(i, 3): o(j, 2) = a(i, 2): o(j, 3) = a(i, 1)
  End If
Next i
With Sheets("Sheet2")
  .Columns(1).Resize(, 3).Clear
  .Cells(1, 1).Resize(UBound(o, 1), UBound(o, 2)) = o
  .Columns(1).Resize(, 3).AutoFit
  .Activate
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the FindWord_V2 macro.
 
Upvote 0
Thank you so much for the code! It really helped me alot! And all the little tips written! It can really help all the newbies here :)
 
Upvote 0
Jesslynn,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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