将 if+or+indirect 函数转换为 vba
converting an if+or+indirect function to vba
你好,我正在尝试转换此函数:
=IF(OR(INDIRECT("'sheet1'!C8")="Nouveau locataire",INDIRECT("'sheet1'!C8")="Décès"),CELL("contents",INDIRECT("'sheet1'!B8")),"")
类似于:
Sub if_orfuction()
Dim i As Integer
j = 2
For i = 2 To Sheets("Sheet1").Range("A1").SpecialCells(xlLastCell).Row
If Sheets("Sheet1").Cells(i, 2).Value = "Nouveau Locataire" Or Sheets("Sheet1").Cells(i, 2).Value = "Décès" Then
Sheets("Sheet3").Cells(j, 1) = Sheets("Sheet1").Cells(i, 1)
j = j + 1
End If
Next i
End Sub
如何在函数中实现间接函数?
试试,
Sub if_orfuction()
Dim i As long, j as long
j = 2
with workSheets("Sheet1")
For i = 2 To .cells.SpecialCells(xlLastCell).Row
If .range(.range("B" & i).Value).Value = "Nouveau Locataire" Or _
.range(.range("B" & i).Value).Value = "Décès" Then
workSheets("Sheet3").Cells(j, "A") = .Cells(i, "A").Value
j = j + 1
End If
Next i
end with
End Sub
你好,我正在尝试转换此函数:
=IF(OR(INDIRECT("'sheet1'!C8")="Nouveau locataire",INDIRECT("'sheet1'!C8")="Décès"),CELL("contents",INDIRECT("'sheet1'!B8")),"")
类似于:
Sub if_orfuction()
Dim i As Integer
j = 2
For i = 2 To Sheets("Sheet1").Range("A1").SpecialCells(xlLastCell).Row
If Sheets("Sheet1").Cells(i, 2).Value = "Nouveau Locataire" Or Sheets("Sheet1").Cells(i, 2).Value = "Décès" Then
Sheets("Sheet3").Cells(j, 1) = Sheets("Sheet1").Cells(i, 1)
j = j + 1
End If
Next i
End Sub
如何在函数中实现间接函数?
试试,
Sub if_orfuction()
Dim i As long, j as long
j = 2
with workSheets("Sheet1")
For i = 2 To .cells.SpecialCells(xlLastCell).Row
If .range(.range("B" & i).Value).Value = "Nouveau Locataire" Or _
.range(.range("B" & i).Value).Value = "Décès" Then
workSheets("Sheet3").Cells(j, "A") = .Cells(i, "A").Value
j = j + 1
End If
Next i
end with
End Sub