背景颜色与偏移结果

时间:2017-03-20 00:03:47

标签: vba excel-vba excel

我有这段代码:

Sub WaterToGeneral()
Application.Calculation = xlCalculationManual 
Application.ScreenUpdating = False
Sheets("water").Activate
Set Water4CabinList = Sheets("water").Range("A2:B" & Range("B" & Rows.Count).End(xlUp).Row)


'Water4CabinList.Select
Sheets("GENERAL").Activate
Set TabGeneral = Sheets("GENERAL").Range("L10:AA" & Range("L" & Rows.Count).End(xlUp).Row)
'TabGeneral.Select

For Each cabin In Water4CabinList.Columns(2).Cells
With TabGeneral
    Set ici = .Find(cabin, lookat:=xlWhole)
        If Not ici Is Nothing Then
            ici.Offset(-1, 0) = cabin.Offset(0, -1)
        End If
End With
Next cabin
Application.Calculation = xlCalculationAutomatic 
Application.ScreenUpdating = True
End Sub

我想放置结果:Offset(-1,0)= cabin.Offset(0,-1) 以背景颜色4为例,我尝试了这个,但它不起作用

With TabGeneral
    Set ici = .Find(cabin, lookat:=xlWhole)
        If Not ici Is Nothing Then
            ici.Offset(-1, 0) = cabin.Offset(0, -1)
            ici. select 
            ici.Offset(-1, 0).Interior.ColorIndex = 4
        End If

0 个答案:

没有答案