searching within cells

cmmadn

Active Member
Joined
Aug 2, 2004
Messages
299
Dear sirs,

I am trying to find a solution to check if a cell contains some particular text as shown below. I know the example does not work, but I would be grateful if someone could tell me how amend the code to make it work.

Code:
    Set rngMovementList = wskMovements.Range("a" & rngClient.Offset(0, 1) & ":a" & rngClient.Offset(0, 2))
    For Each rngMovement In rngMovementList
    
        If rngMovement.Offset(0, 1).Find("Cash received") = True Then
            rngMovement.Offset(0, 8) = 1
        ElseIf rngMovement.Offset(0, 1).Find("subscription") = True Then
            rngMovement.Offset(0, 8) = 2
        ElseIf rngMovement.Offset(0, 1).Find("interest") = True Then
            rngMovement.Offset(0, 8) = 3
        ElseIf rngMovement.Offset(0, 1).Find("Purchase") = True Then
            rngMovement.Offset(0, 8) = 4
        ElseIf rngMovement.Offset(0, 1).Find("Sale") = True Then
            rngMovement.Offset(0, 8) = 5
        ElseIf rngMovement.Offset(0, 1).Find("Income") = True Then
            rngMovement.Offset(0, 8) = 7
        ElseIf rngMovement.Offset(0, 1).Find("withdrawals") = True Then
            rngMovement.Offset(0, 8) = 6
        ElseIf rngMovement.Offset(0, 1).Find("fees") = True Then
            rngMovement.Offset(0, 8) = 8
        End If
        
    Next rngMovement

with thanks

Andrew
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
"Instr" would be a candidate. Maybe something like this (for all of them):

Code:
If InStr(UCase(rngmovement.Offset(0, 1).Text), "CASH RECEIVED") Then

I believe it is case sensitive so you would probably want use use UCase or LCase.

Hope it helps.

Gary
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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