|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
要把rg2(红色单元格区域)的61个时间、以及该时间对应的员工编号、 员工姓名、 签卡日期 整理到sheets(1)的各列,
形成一个缺卡记录。
这个单元格区域处理不了,请各位大侠帮助。谢谢!!!!
在线等。谢谢 谢谢谢谢谢谢谢谢谢谢
Sub qianka()
Sheets.Add.Move Before:=ActiveSheet
Sheets(2).Select
Dim rg, rg2 As Range
Dim cishu, i As Integer
Set rg2 = ActiveSheet.Range(Cells(1, 8), Cells(Range("A1").CurrentRegion.Rows.Count, 11)).SpecialCells(xlCellTypeBlanks)
cishu = rg2.Cells.Count
With rg2.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
For Each rg In rg2
If rg.Column = 8 Then rg.Value = "08:30:00"
If rg.Column = 9 Then rg.Value = "12:00:00"
If rg.Column = 10 Then rg.Value = "13:30:00"
If rg.Column = 11 Then rg.Value = "18:00:00"
Next
' Dim cel, rg_1 As Range
' Dim arr() As Variant
' Dim n As Integer
'
'
' arr() = rg2.Value
'
' For n = 0 To cishu
' ReDim Preserve arr(n)
' arr(n) = rg2 '从大到小写入数组
' Next
' Next
'
' k = 0
' For Each cel In Range(Cells(2, 4), Cells(cishu + 1, 4))
' cel = arr(k) '数组赋值到单元格
' k = k + 1
' Next cel
'
'
'
'rg2.Select
'
'Set rg2 = Selection
'
'Dim arr
'
'Set arr = rg2
'
'
'ActiveSheet.Range(Cells(2, 4), Cells(cishu + 1, 4)).Value = arr.Value
'
'
For i = 1 To cishu
Sheets(1).Cells(i + 1, 1) = Cells(rg2.Cells(i).Row, 1).Value
Sheets(1).Cells(i + 1, 2) = Cells(rg2.Cells(i).Row, 2).Value
Sheets(1).Cells(i + 1, 3) = Cells(rg2.Cells(i).Row, 4).Value
Sheets(1).Cells(i + 1, 4) = rg2.Value
Sheets(1).Cells(i + 1, 5).Value = "正常签卡"
Next i
Sheets(1).[A1:F1] = Array("员工编号", "员工姓名", "签卡日期", "时间", "签卡类型", "事由")
With Sheets(1).Range("A1:F1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Interior.Pattern = xlSolid
.Interior.PatternColorIndex = xlAutomatic
.Interior.ThemeColor = xlThemeColorLight2
.Interior.TintAndShade = 0.799981688894314
.Interior.PatternTintAndShade = 0
End With
End Sub
|
|