Sub isColInfo(sheet As Worksheet)Dim LastRow As IntegerDim arrCol As VariantarrCol = Array("C", "D", "E")'等下需要遍历、修改C、D、E列,并修改这几列除加粗文字(表头)外的文字对齐方式For k = 0 To UBound(arrCol)'获取最后一行非空单元格的行号LastRow = ActiveSheet.Cells(Rows.Count, arrCol(k)).End(xlUp).Row'判断最后一行的行号是否大于0If LastRow > 0 ThenFor i = 1 To LastRow'判断这个单元格是否为空If Cells(i, arrCol(k)) <> "" Then'判断这个单元格的字体是否加粗,如果没加粗,则进行后续操作If Cells(i, arrCol(k)).Font.Bold = False ThenApplication.DisplayAlerts = False'禁止弹窗提示,因为修改合并单元格字体内容时会有弹窗提示'设置这个单元格字体:水平左对齐,垂直居中对齐,行高设为33With Cells(i, arrCol(k)).HorizontalAlignment = xlLeft.VerticalAlignment = xlCenter'垂直顶部对齐'.VerticalAlignment = xlTop.RowHeight = 33End WithEnd IfEnd IfNext iEnd IfNext kEnd Sub