Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
Bianca777 pe Simpatie.ro
Femeie
19 ani
Brasov
cauta Barbat
19 - 61 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] Check for String in Cell Offset, Then Color Some Cells Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 739
InStr syntax:
InStr(start, String1, String2, Compare)

start
Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.

string1
Required. String expression being searched. For example cell.Value

string2
Required. String expression sought.

compare
Optional. Specifies the type of string comparison. If compare is Null, an error occurs. If compare is omitted, the Option Compare setting determines the type of comparison. Specify a valid LCID (LocaleID) to use locale-specific rules in the comparison.

compare types:
vbUseCompareOption     -1     Performs a comparison by using the setting of the Option Compare statement.
vbBinaryCompare          0     Performs a binary comparison.
vbTextCompare               1     Performs a textual comparison.
vbDatabaseCompare          2     Microsoft Access only. Performs a comparison based on information in your database.

Source:


Sub Color_Cells_Based_On_Contents()
Application.ScreenUpdating = False

Dim rng As Range
Set rng = Selection

For Each cell In rng

If InStr(1, cell.Offset(0, -2).Value, "AAA", vbTextCompare) Then
    cell.Offset(0, 3).Interior.ColorIndex = 6
        cell.Offset(0, 1).Interior.ColorIndex = 6
            cell.Offset(0, 2).Interior.ColorIndex = 6
    cell.Offset(0, -3).Interior.ColorIndex = 6
   
ElseIf InStr(1, cell.Offset(0, -2).Value, "BBB", vbTextCompare) Then
    cell.Offset(0, 3).Value = "some text goes here, or numbers, or whatever"
    cell.Offset(0, 3).Interior.ColorIndex = 6
        cell.Offset(0, 1).Value = "more text here, or numbers, or whatever"
        cell.Offset(0, 1).Interior.ColorIndex = 6
            cell.Offset(0, 2).Value = "even more here"
            cell.Offset(0, 2).Interior.ColorIndex = 6
    cell.Offset(0, -3).Interior.ColorIndex = 6
End If

Next cell

Application.ScreenUpdating = True
End Sub


pus acum 3 saptamani
   
Pagini: 1  

Mergi la