0

## 尋找最後一列的某字串

### 3 個回答

0
paicheng0111
iT邦高手 1 級 ‧ 2019-06-13 13:24:59

``````Sub test()
Dim myRng As Range, i As Long

Set myRng = Cells(Rows.Count, 1).End(xlUp)
For i = myRng.Row To 1 Step -1
With Cells(i, 1)
If .Value = "六" Then
.Borders(xlEdgeBottom).LineStyle = xlDouble
Exit For
End If
End With
Next i

i = i - 14
Do Until i <= 0
With Cells(i, 1)
If .Value = "六" Then
.Borders(xlEdgeBottom).LineStyle = xlDouble
End If
End With

i = i - 14
Loop
End Sub
``````
no1kent iT邦新手 5 級 ‧ 2019-06-14 06:26:20 檢舉

PCW，不好意思，如果雙底線不是只有一格，還要延伸到Z56，要加什麼程式碼呢?

``````.Borders(xlEdgeBottom).LineStyle = xlDouble
``````

``````Range(.Cells(1, 1), .Cells(1, 26)).Borders(xlEdgeBottom).LineStyle = xlDouble
``````
no1kent iT邦新手 5 級 ‧ 2019-06-14 10:46:24 檢舉

0
listennn08
iT邦高手 7 級 ‧ 2019-06-13 11:42:25

``````For i = 1 To 60
If Cells(i * 14, 1) = "六" Then
Cells(i * 14, 1).Font.Underline = xlUnderlineStyleSingle
End If
Next
``````

``````For i = lastSaturday To 1 Step -1
If i Mod 14 = 0 And Cells(i, 1) = "六" Then
Cells(i, 1).Font.Underline =xlUnderlineStyleSingle
End If
Next
``````

`````` Cells(i-14, 1).Font.Underline =xlUnderlineStyleSingle
``````

0

iT邦大師 1 級 ‧ 2019-06-13 13:58:35
``````Private Sub Test()
Dim lastRow As Integer
lastRow = Cells(1, 1).End(xlDown).Row
Dim i As Integer
For i = lastRow To 1 Step -1
If Cells(i, 1).Value = "六" Then
Cells(i, 1).Font.Underline = xlUnderlineStyleDoubleAccounting
If i - 14 > 0 Then
Cells(i - 14, 1).Font.Underline = xlUnderlineStyleDoubleAccounting
End If
MsgBox ("完成!")
Exit For
End If
Next
End Sub
``````