请帮我改变下面的代码。需要通过func (a ByTimestamp) Less(i, j int) bool {
return a[j].Timestamp.Before(a[i].Timestamp)
}
由于
InputBox
答案 0 :(得分:1)
有几种方法可以使用InputBox
访问Cell C4。
一种方法是在String
中选择InputBox
,请参阅以下代码:
Dim RngStr As String
RngStr = Application.InputBox(prompt:="Select the Cell for the new Sheet's name", Type:=2)
If Trim(.Range(RngStr)) <> "" Then
另一种方法是选择Range
中的InputBox
,请参阅以下代码:
Dim rng As Range
Set rng = Application.InputBox(prompt:="Select the Cell for the new Sheet's name", Type:=8)
If Trim(rng) <> "" Then
Option Explicit
Sub RenWSs()
Dim WS As Worksheet
Dim shtName
Dim newName As String
Dim i As Integer
Dim RngStr As String
RngStr = Application.InputBox(prompt:="Select the Range for the new Sheet's name", Type:=2)
For Each WS In Worksheets
With WS
If Trim(.Range(RngStr)) <> "" Then
shtName = Split(Trim(.Range(RngStr)), " ")
newName = shtName(0)
On Error GoTo ws_name_error
.Name = newName
GoTo done
repeat:
.Name = newName & i
GoTo done
ws_name_error:
i = i + 1
Resume repeat
End If
End With
On Error GoTo 0
done:
Next
End Sub
要详细了解InputBox
功能:https://msdn.microsoft.com/en-us/library/office/ff839468.aspx