Можно ли начать диапазон со слова заголовка столбца?

Убедитесь, что ваше возвращаемое значение выбора является строкой, а не и int, когда вы объявляете ее в своей модели.

Пример:

public class MyModel
{
    public string TipPopustaId { get; set; }
}
0
задан dwirony 26 March 2019 в 20:29
поделиться

1 ответ

Прочтите это и посмотрите, полезно ли это. Вы бы назвали эту подпрограмму с именем вашего заголовка в столбце А.

Sub ScanAndColor(tblName As String)

    Dim row As Integer
    row = 1

    'scan down until you find tblName, this is like "STEPS" or "STEPS1" or whatever
    Do While Cells(row, 1).Text <> tblName

        'just read the next row
        row = row + 1

        'since we're letting someone else tell us what value to stop at, maybe we should add some infinite loop protection
        If row = 1000 Then GoTo EscapeHatch
    Loop

    'push down one column to start reading just under the headers
    row = row + 1

    'scan down through the table until we hit some whitespace
    Do While Cells(row, 1).Text <> ""

        'in each iteration, grab every 3rd column from col 2 and assign it a color
        '  according to the code in the first cell.
        For col = 2 To 14 Step 3
            Cells(row, col).Interior.Color = Cells(Cells(row, 1) + 15, 2).Interior.Color

        Next col

        'increment the row
        row = row + 1
    Loop

EscapeHatch:
End Sub
0
ответ дан Ryan B. 26 March 2019 в 20:29
поделиться
Другие вопросы по тегам:

Похожие вопросы: