|
兰埔东有三张照片,对应的是公交第三站。
采用的是Union方法。
- Sub lll()
- Dim ii, kk
- Dim oRng As Range, Rng As Range, Rng1 As Range, Rng2 As Range
- Set Rng1 = Cells(5, "B").CurrentRegion
- Set Rng2 = Cells(5, "G").CurrentRegion
- For ii = 1 To Rng2.Rows.Count
- Set Rng = UnionRng(Rng1, Rng2(ii, 1))
- Rng2(ii, 5) = "=" & Rng.Address(0, 0)
- Rng(, 0).Resize(Rng.Rows.Count, 1) = "第" & ii & "站'"
-
- Next ii
- End Sub
- Function UnionRng(Rng As Range, Str)
- Dim oRng As Range
- Set oRng = Rng.Find(Str)
- Debug.Print oRng.Address
- For ii = 1 To Rng.Rows.Count
- If Rng(ii, 1) = Str Then
- Set oRng = Union(oRng, Rng(ii, 1))
- Debug.Print oRng.Address
- End If
- Next
- Set UnionRng = oRng
- End Function
复制代码
|
|