A
A
Andrey Bondarchuk2015-03-16 09:18:50
Visual Basic
Andrey Bondarchuk, 2015-03-16 09:18:50

How to number cells by content?

There is a table of the form
7c6b459795954fe8b131d4b156a59173.png
It is necessary, in accordance with the contents of cell B, to number cells C. (It is the condition "contains", not "equals" that is of interest.) I see this approximately as below, but I have no experience with VBA, so something goes otherwise, the macro is not executed, and no errors are output.

Sub Numer()

Dim i As Integer
Dim SHEET0 As String
Dim Novoal As String
Dim Stav As String
Dim Chr As String
SHEET0 = "16.03.15"

Novoal = "Новоалександровский "
Stav = "Ставрополь"
Chr = "Черкесск"

For i = 2 To SHEET0_STR
    Application.StatusBar = "Ждите" & Str(i)
    REGNUMBER = Val(Worksheets(SHEET0).Cells(i, "С").Value)

  If (Worksheets(SHEET1).Cells(i, "B").Value Like Novoal) Then
            Worksheets(SHEET0).Cells(i, "С").Value = 1
  End If
    If (Worksheets(SHEET0).Cells(i, "B").Value Like Stav) Then
             Worksheets(SHEET0).Cells(i, "С").Value = 2
  End If
      If (Worksheets(SHEET0).Cells(i, "B").Value Like Chr) Then
            Worksheets(SHEET0).Cells(i, "С").Value = 3
  End If
  Next i
End Sub

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question