Recent studies VBA in Excel, Excel macro that is, the value needs to be the first page, and so on into the second column of page Sheet
Like the first page
Arranged
Like this
First need to continuously own ideas
We need to get to the first Sheet also of value
Set Destination = Worksheets("Sheet1")
After the acquisition, how to find the value of each column and assign it to another Sheet?
Of course, the cycle is written +
A of As Integer Dim Dim B of As Integer Dim JS of As Integer the Set the Destination = Worksheets ( "Sheet1") the Set DESTINATION2 = Worksheets ( "Sheet2") 'rows A = Destination.UsedRange.Rows.Count ' number of columns b = Destination.UsedRange .Columns.Count 'circulation line the For the to. 1 I = a ' column cycle the For the to J = B. 1 'location calculation line JS = (I * 2) ' different columns of different data processing the If (J = 2) the Then DESTINATION2. Cells (JS,. 1 + J) = Destination.Cells (I, J) ElseIf (J =. 3) the Then Destination2.Cells (JS -. 1, J) = Destination.Cells (I, J) Else Destination2.Cells(js - 1, j) = Destination.Cells(i, j) Destination2.Cells(js, j) = Destination.Cells(i, j) Destination2.Cells(js - 1, j + 1) = Destination.Cells(i, j) Destination2.Cells(js, j + 1) = Destination.Cells(i, j) End If Next Next
Which is used to define a variable Dim
Sheet acquired by your page data is to take your .Cells XY corresponding to a certain data, can also be directly assigned
For syntax is For variable = initial value To end value
Next
If the syntax is simple
IF (condition) then your code or else no condition can not write End If
Then do the following, we take a look
It is not so easy?
Just in case, you can join most layer If Not IsError
His usage and if similar, If Not IsError (you think may be error row) Then if there is no error, then the error else if On Error Resume Next
So, if we want the cell a little bit beautiful, plus tables how to do it?
With ActiveSheet.UsedRange.Resize(x, b - 1).Borders .LineStyle = xlContinuous .Weight = xlThin End With
简简单单一个 with 循环搞定
最后来个友情的弹出框
result = MsgBox("转换完成", 0, "提示")
至于弹出框还有什么样式,https://www.yiibai.com/vba/vba_message_box.html 阔以看看这里哟
当然里面以及空行删除啊,或者自行填充啊,这个就是你的逻辑代码需要处理的事情了
理论上知识点,差不多就这些吧
共同学习