1

是否可以在运行时的列级别设置日期格式,比如#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

谢谢

4

1 回答 1

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 的网站

在此处输入图像描述

于 2012-12-27T18:38:31.027 回答