excel表宏代码翻译

Sub EnableControl(Id As Integer, Enabled As Boolean)

Dim CB As CommandBar
Dim C As CommandBarControl

On Error Resume Next
For Each CB In Application.CommandBars
Set C = CB.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = Enabled

Next

End Sub

第1个回答  2013-06-06
Sub zhibiaoModify()

Dim tmp As Integer
Dim str As String
On Error GoTo 0

For iSheet = 3 To 16

ThisWorkbook.Sheets(iSheet).Activate

For iRow = 1 To 100
If (ThisWorkbook.Sheets(iSheet).Cells(iRow, 1).Value) = "Sheet1" Then
startRow = iRow + 1
Exit For
End If
Next

For iRowModify = startRow To 100
If (IsNumeric(trimAllBlank(ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 1).Value))) Then
tmp = ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 1).Value
ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 2).Value = tmp & "." & ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 2).Value
ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 1).Value = ""
ThisWorkbook.Sheets(iSheet).Range(Cells(iRowModify, 1), Cells(iRowModify, 2)).Merge

str = ThisWorkbook.Sheets(iSheet).Cells(iRowModify, 1).Value

str = Replace(str, ":", ":")

arr = Split(str, ":")

ipos = Len(arr(0)) + 1

RangeStr = "A" & iRowModify
Range(RangeStr).Select

With ActiveCell.Characters(Start:=1, Length:=ipos).Font
.Name = "宋体"
.FontStyle = "加粗"
.Size = 10
End With

With ActiveCell.Characters(Start:=ipos + 1).Font
.Name = "宋体"
.FontStyle = "常规"
.Size = 10
End With

End If
Next
Next

End Sub

Function trimAllBlank(trimStr As String)
If InStr(trimStr, " ") > 0 Then
trimStr = Replace(trimStr, " ", "")
End If

trimAllBlank = trimStr

End Function