- ·上一篇:excel表格打印表格怎么不显示完
- ·下一篇:excel表格散点图标签怎么设置
excel表格数量怎么变成一排
1.EXCEL 怎么把几列数据变成一列,即每一行转置后,后接下一行转
可以写VBA代码解决。
代码如下: Sub test()'-------------------声明变量-------------------Dim wb As Workbook, Sh As Worksheet, mRow As Integer, mCol As IntegerDim mPath As String, Fx As String, i As Integer, mAryOn Error Resume Next '容错'-------------------工作环境初始化-------------------t = TimerIf Workbooks.Count > 1 Then MsgBox "关闭其他工作簿后,再运行本程序!": Exit Sub'-------------------获取源文件路径-------------------MsgBox "在接下来的对话框中,选择源数据所在的文件夹。" & Chr(10), vbOKOnly, "提示"With Application.FileDialog() .AllowMultiSelect = False .Show If .SelectedItems.Count = 0 Then MsgBox "没有选择任何文件夹!": Exit Sub mPath = .SelectedItems(1)End With'-------------------枚举文件夹中的Excel文件,并进行相应处理-------------------Application.ScreenUpdating = FalseApplication.DisplayAlerts = FalseApplication.Calculation = xlCalculationManualFx = Dir(mPath & "\*.xls*")Do While Fx <> "" If Fx <> ThisWorkbook.Name Then Set wb = Workbooks.Open(mPath & "\" & Fx, , False) Set Sh = wb.Worksheets("每木调查") If Err.Number > 0 Then Err.Clear: GoTo NA Sh.Copy after:=wb.Worksheets(wb.Worksheets.Count) Set Sh = ActiveSheet Sh.Name = "新表" With Sh mRow = .Cells(Rows.Count, 2).End(3).Row For i = mRow To 2 Step -1 mCol = .Cells(i, Columns.Count).End(xlToLeft).Column If mCol = 4 Then mAry = .Cells(i, 4).Value .Rows(i + 1).Insert shift:=xlDown .Cells(i + 1, 3) = mAry ElseIf mCol >= 4 Then mAry = .Range(.Cells(i, 4), .Cells(i, mCol)) .Rows(i + 1 & ":" & i + UBound(mAry, 2)).Insert shift:=xlDown .Cells(i + 1, 3).Resize(UBound(mAry, 2), 1) = Application.Transpose(mAry) End If Next i .Columns("D:AZ").Delete End With End IfNA:wb.Close TrueFx = DirLoopApplication.ScreenUpdating = TrueApplication.DisplayAlerts = TrueApplication.Calculation = "处理结束!共耗时" & Timer - t & "秒。
"End Sub。
2.excel表格中如何将所有数据排成一行
如果表格中有数据的最大行为10行
A11=OFFSET($A$1,MOD((ROW()-1),10),INT((ROW()-1)/10))
向下复制公式
复制-选择性粘贴,去掉公式
在b1输入1,b2输入2,b3=3……
选中a、b两列
按a列排序,删除空行
按b列排序,删除b列
不好意思,看成合并为1列了,
如果表格中有数据的最大列为10
K1=OFFSET($A$1,INT((COLUMN()-1)/10),MOD((COLUMN()-1),10))
其他操作于合并为1列差不多,只不过是在插入1行
按行排序