是否可以在运行时在列级别设置日期格式,如列#9
我需要将日期格式设置为[h]:mm:ss
?我会在将数组转换到该列之前设置格式。
编辑
Sub Macro1()
'
' Macro1 Macro
'
'
Range("D1").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End Sub
由于
答案 0 :(得分:2)
ob.Range.Column(9).format = [h]:mm:ss
上述内容必须写成
oXLWs.Columns(9).NumberFormat = "[h]:mm:ss"
其中oXLWs
是相关表格。例如,
Dim oXLApp, oXLWb, oXLWs
Set oXLApp = CreateObject("Excel.Application")
oXLApp.Visible = True
Set oXLWb = oXLApp.Workbooks.Add
Set oXLWs = oXLWb.Sheets("Sheet1")
oXLWs.Columns(9).NumberFormat = "[h]:mm:ss"
<强>后续强>
这是你想要的吗?
Dim oXLApp, oXLWb, oXLWs
Set oXLApp = CreateObject("Excel.Application")
oXLApp.Visible = True
Set oXLWb = oXLApp.Workbooks.Add
Set oXLWs = oXLWb.Sheets("Sheet1")
With oXLWs.Columns(9)
.NumberFormat = "[h]:mm:ss"
.Interior.ColorIndex = 6 '<~~ Yellow
.Font.Bold = True '<~~ Bold
.Font.ColorIndex = 3 '<~~ Red
End With
我将这张旧照片称为正常颜色(从dmcritchie的site中选取)