作者:乔山办公网日期:
返回目录:excel表格制作
拷贝上面的程序到你的excel宏中运行zhidao,将会把sheet1中E4:M5区域中的数据以行优先的方式逐行拷贝到sheet2中的C2:E7区域中,拷贝三个数后自动换行版。如果源区域或目标区域不同,只需权按注释修改相应变量的值。
录制一制下宏就有了。
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
=百=========
就是这一句改一下度:range("A1").WrapText = True
关键在a的值, 不知你的cells(3,4).value是什么?
建议用以下语句:
a=[b65536].end(xlup).row+1
Private Sub Worksheet_Change(ByVal Target As Range)
r = Target.Row
If Len(Cells(r, 5)) > 0 And Target.Column < 5 Then
Application.EnableEvents = False
If Len(Cells(r + 1, 1)) = 0 Then
Cells(r + 1, 1) = Cells(r, 5)
Cells(r, 5) = ""
Application.EnableEvents = True
Else
If Len(Cells(r + 1, 4)) = 0 Then
Range("A" & r + 1).Insert xlShiftToRight
Cells(r + 1, 1) = Cells(r, 5)
Cells(r, 5) = ""
Application.EnableEvents = True
Else
Range("A" & r + 1).Insert xlShiftToRight
Application.EnableEvents = True
Cells(r + 1, 1) = Cells(r, 5)
Cells(r, 5) = ""
End If
End If
End If
End Sub