我试图在包含特定值的列中替换列中的值。到目前为止,我有两个独立工作的查询,但现在我试图让它们一起工作。尝试了很多东西来整合它们但到目前为止没有运气。谢谢!
Sub FindAddressColumn()
Dim rngAddress As Range
Set rngAddress = Range("A1:Z1").Find("Location")
If rngAddress Is Nothing Then
MsgBox "Address column was not found."
Exit Sub
End If
Range(rngAddress, rngAddress.End(xlDown)).Select
End Sub
Sub findrep()
Dim i As String
Dim k As String
i = "1"
k = "2"
Columns("B").Replace what:=i, replacement:=k, lookat:=xlPart, MatchCase:=False
End Sub
答案 0 :(得分:0)
像这样:
Sub findrep()
Dim i As String
Dim k As String
Dim rngAddress As Range
i = "1"
k = "2"
Set rngAddress = Range("A1:Z1").Find("Location")
If rngAddress Is Nothing Then
MsgBox "Address column was not found."
Exit Sub
End If
Range(rngAddress, rngAddress.End(xlDown)).Replace what:=i, replacement:=k, lookat:=xlPart, MatchCase:=False
End Sub