select多个列并将格式设置为date

我试图select列I,K,Q,R和格式从第2行作为date(mm / dd / yyyy)的整个列我知道这段代码将select我不需要的所有列。 任何人都可以帮助我与VBA代码? 谢谢! 我包含了一部分代码,询问是否可以在第一部分代码中包含date格式。 wsMain是你的信息表

With wsMain .Columns("A:AO").AutoFit .Cells.ClearFormats .Rows(1).Font.Bold = True .Cells.Font.Name = "Georgia" .Cells.Font.Color = RGB(0, 0, 225) .Cells.Resize(.Rows.Count - 1).Offset(1).Interior.Color = RGB(216, 228, 188) Sub SelectColumn() Dim xColIndex As Integer Dim xRowIndex As Integer xIndex = Application.ActiveCell.Column xRowIndex = Application.ActiveSheet.Cells(Rows.Count, xIndex).End(xlUp).Row Range(Cells(2, xIndex), Cells(xRowIndex, xIndex)).Select 

你尝试这样简单的事情

 Option Explicit Sub DateFormat() Dim rng As Range Dim rngArea As Range '// set your range Set rng = Range("I1:I10, K1:K10, Q1:Q10, R1:R10") For Each rngArea In rng.Areas With rngArea .NumberFormat = "MM/DD/YYYY" End With Next rngArea End Sub 

例2

 Sub DateFormat() '// (9) = I Columns(9).NumberFormat = "MM/DD/YYYY" Columns(11).NumberFormat = "MM/DD/YYYY" Columns(17).NumberFormat = "MM/DD/YYYY" Columns(18).NumberFormat = "MM/DD/YYYY" End Sub