我需要根据用户输入使用vba将一个单元格变灰

时间:2016-07-25 16:26:49

标签: excel vba excel-vba

所以我有这个信息列表,我需要用户提交,以便它可以包含在另一张表中。(见下图)我希望这个代码在选择另一行时变灰。因此,如果用户输入"开始"时间,然后我想要"依赖"灰显,用户无法使用它。如果用户点击"依赖"那么"开始时间"需要变灰。这是我目前的代码。

enter image description here

Sub findData()
    Dim finalrow As Integer
    Dim i As Integer
    Dim workflows As String

    With Sheets("Sheet1")
        workflows = .Range("C5").Value
        servergri = .Range("C9").Value
        gridf = .Range("C9").Value
        StartTime = .Range("c11").Value
    End With

    With Sheets("Sheet3")
        finalrow = .Range("C" & Rows.Count).End(xlUp).Row

        For i = 5 To finalrow
            If .Cells(i, 3) = workflows And (.Cells(i, 4) = servergri Or .Cells(i, 5) = gridf) Then

                .Rows(i).Insert
                'Add new information to the new row.
                'The new row number is still = i

                .Cells(i, 3) = workflows
                .Cells(i, 4) = servergri
                .Cells(i, 6) = StartTime
                    .Cells(i, 3).Resize(2, 4).Interior.ColorIndex = 8



                'If you only want to add one row then your should exit the loop
                Exit For
            End If
        Next
    End With
    Sheets("Sheet1").Range("c9").ClearContents

End Sub

0 个答案:

没有答案