乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>Excel</em> 用<em>VBA</em>怎样实现<

<em>Excel</em> 用<em>VBA</em>怎样实现<

作者:乔山办公网日期:

返回目录:excel表格制作


解决办法如下

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column > 5 Then
Cells(Target.Row + 1, 1).Select
End If
End Sub

上面是>5,即数据输到E列,再往右就会换行。

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
不用vba可以吗?将单元格内容复制到记事本中,然后再粘贴回excel中就可以了

选中要进行处理的zd这个单元格,运行下面的宏。
Sub 分行()
x = Selection.Value
For i = 1 To Len(x) Step 3
y = y & Mid(x, i, 3) & vbCrLf
Next i
Selection.Value = y
End Sub

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网