Home > Software engineering >  ==how Excel data, please according to the number of split==
==how Excel data, please according to the number of split==

Time:11-06

Data split out the corresponding number of data according to the amount of it -- -- --

The following figure

Do you have a little bit more simple method, the data quantity is too large split up is a waste of time
Can automatic split?

CodePudding user response:

Got two worksheet, the first sheet1, depositing you above the original data, the second sheet2, deposited as a result, a macro, macro code as follows, tried, basic can get requirements:

 Sub Macro1 () 
Dim I, j As Integer
Dim iRow As Integer

For I=2 To Sheet1. UsedRange. Rows. Count
Sheet1. Select
Sheet1. Range (" A "& amp; I & amp; : "G" & amp; I). Select
Selection. Copy
Sheet2. Select
Sheet2. Range (" A "& amp; (Sheet2. UsedRange. Rows. Count + 1)). Select
ActiveSheet. Paste

If the Trim (Sheet1. Cells (I, 2)) & lt;> "" Then
If Sheet1. Cells (I, 2) & gt; 1 Then
IRow=Sheet2. UsedRange. Rows. Count + 1

Sheet2. Cells (iRow, 2)=1
Sheet2. Cells (iRow, 3)=Sheet1. Cells (I, 3)/Sheet1 Cells (I, 2)
Sheet2. Cells (iRow, 4)=Sheet1. Cells (I, 4)/Sheet1 Cells (I, 2)
Sheet2. Cells (iRow, 5)=Sheet1. Cells (I, 5)/Sheet1 Cells (I, 2)
Sheet2. Cells (iRow, 6)=Sheet1. Cells (I, 6)/Sheet1 Cells (I, 2)

Sheet2. Range (" B "& amp; IRow & amp; : "G" & amp; IRow). Select
Selection. Copy
Sheet2. Range (" B "& amp; IRow & amp; : "G" & amp; IRow + Sheet1. Cells (I, 2) - 1). Select
ActiveSheet. Paste
End the If
End the If
Next

End Sub
  • Related