InStr problem

Alexandro88

New Member
Joined
Nov 11, 2010
Messages
35
Code:
If [COLOR="Red"]Myday = InStr(1, Left(rngcell.Value, 5), "Sun" Or "Sat" Or "Mon" Or "Tue" Or "Wed" Or "Thu" Or "Fri")[/COLOR] Then
         If InStr(1, Left(rngcell.Value, 3), "LRR") Then
            Cells.Value = lr_Total
         ElseIf InStr(1, Left(rngcell.Value, 3), "OP3") Then
            Cells.Value = zResult_Total_NSOP
         ElseIf InStr(1, Left(rngcell.Value, 3), "OP4") Then
            Cells.Value = vResult_Total_NSOP
         ElseIf InStr(1, Left(rngcell.Value, 3), "OL3") Then
            Cells.Value = vResult_Total_NSOL
         ElseIf InStr(1, Left(rngcell.Value, 3), "OL4") Then
            Cells.Value = zResult_Total_NSOL
         End If
    End If

I get erro for the red line. Can anyone help me and provide solution to me?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
means:
Mayday= Monday

Then , i need to loop through every column to find the word that match
example:
Monday = mon in that column.
 
Upvote 0
Yes, but aren't your headings in a single row in columns A:DI? If not you can use the Find method to locate the cell.
 
Upvote 0
Example :
Column A : Mon
Column B: Tue
Column C: Wed
Column D : Thur
Column E : Fri
Column F : Sat
Column G : Sun

Then, Mayday = Monday.
So, i want loop through the column and findwhich 1 match with monday and input the data in that that column row
 
Upvote 0
Adapting what I posted earlier:

Code:
Sub Test()
    Dim Rng As Range
    Dim Myday As String
    Dim Col As Long
    Set Rng = Range("A1:G1")
    Myday = Format(Cells(1, 17).Value, "ddd")
    Col = WorksheetFunction.Match(Myday, Rng, False)
    MsgBox Col
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,048
Members
453,014
Latest member
Chris258

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