|
楼主 |
发表于 2024-10-5 13:25
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
谢谢回复,不太会用数组法。还需要进一步消化理解。
现在还在钻牛角尖,没有出来。
*********************
$A$48 $A$10 澳门 > 北区-1(青洲区、筷子基区及林茂塘区)
$A$49 $A$10 澳门 > 北区-1(青洲区、筷子基区及林茂塘区)
$A$50 $A$10 澳门 > 北区-1(青洲区、筷子基区及林茂塘区)
$A$51 $A$10 澳门 > 北区-1(青洲区、筷子基区及林茂塘区)
$A$53 $A$52 澳门 > 北区-2(台山区、黑沙环及佑汉区)
$A$54 $A$52 澳门 > 北区-2(台山区、黑沙环及佑汉区)
If InStr(Rng(ii, 1), "澳門 >") > 0 Then
Str = FtoJ(Rng(ii, 1))
Set oRng = Sht1.Cells(Rr, 1)
End If
A10变成A52时,条件语句没有用好。
If Sht1.Cells(Rr, 1) <> oRng Then
Debug.Print Sht1.Cells(Rr, 1).Address, oRng.Address, oRng
End If
*************************
- Sub lll()
- Dim Rng As Range, oRng As Range
- Dim Sht As Worksheet, Sht1 As Worksheet
- Set Sht = Sheet1
- Set Sht1 = Sheet2
- Sht1.Cells.Clear
-
- Dim Shp As Shape
-
- Dim Rr, Kk, Str
- Rr = 10
- With Sht
- Debug.Print .Cells(655536, 1).End(xlUp).Row, .Cells(1, 1).End(xlDown).Row
- Set Rng = .Cells(1, 1).End(xlDown)
-
- 'Set Rng = Rng.Resize(.Cells(655536, 1).End(xlUp).Row - Rng.Row + 1)
- Set Rng = .Range(.Cells(.Cells(1, 1).End(xlDown).Row, 1), .Cells(.Cells(655536, 1).End(xlUp).Row + 1, 1))
- Debug.Print Rng.Address
- End With
- For ii = 1 To Rng.Rows.Count
- If InStr(Rng(ii, 1), "澳門 >") > 0 Then
- Str = FtoJ(Rng(ii, 1))
- Set oRng = Sht1.Cells(Rr, 1)
- End If
- If Rng(ii, 1) <> "" Then
-
- If Asc(Rng(ii, 1)) >= 65 And Asc(Rng(ii, 1)) <= 122 Then
- If Sht1.Cells(Rr, 1) <> oRng Then
- Debug.Print Sht1.Cells(Rr, 1).Address, oRng.Address, oRng
-
- End If
- Sht1.Cells(Rr, 1) = Str
- 'Debug.Print Sht1.Cells(Rr, 1).Address, oRng.Address, Sht1.Cells(Rr, 1), oRng
- Sht1.Cells(Rr, 2) = Rng(ii, 1)
- Sht1.Cells(Rr, 3) = FtoJ(Rng(ii + 1, 1))
-
-
- Rr = Rr + 1
- End If
- End If
- '
- 'Debug.Print Rng(ii, 1), Rng(ii + 2, 1)
- 'End If
- Next ii
-
- End Sub
复制代码 |
|