Creating an excel worksheet VA code

2019-09-16 05:32发布

I am trying to create a macro in which I want to delete and cut some values and then paste that values in next cell.
e.g.

 A                                    
----                                  
apple, fruit

After macro execution

 A          B                               
----       --- 
apple      fruit

How could I make such macro for an lengthy list?

2条回答
戒情不戒烟
2楼-- · 2019-09-16 06:10

If you want to make some columns from one column in Excel follow this:

At first select all cells you want to split them.

In Data tab One of tools listed in Data Tools section is text to Columns.

After selecting that, a wizard window will show.

Select Delimited option, and Next.
Select Comma check, and Finish.


If you need a macro for it use Macro Recorder.

查看更多
姐就是有狂的资本
3楼-- · 2019-09-16 06:21

You could try this:

Sub cutAndPaste()
'
' cutAndPaste Macro
'
'
Dim Column_index As Integer
Dim Row_index As Integer
Column_index = 5
Row_index = 7

Cells(Row_index + 1, Column_index).Value = Cells(Row_index, Column_index).Value
Cells(Row_index + 1, Column_index + 1).Value = Cells(Row_index, Column_index + 1).Value
Cells(Row_index, Column_index).Value = ""
Cells(Row_index, Column_index + 1).Value = ""

End Sub

I think it works, hope be helpful.

查看更多
登录 后发表回答