zoukankan      html  css  js  c++  java
  • 20170728xlVBA改转置一例

    Sub 导出()
        
        Dim Sht As Worksheet, ShtName As String
        Dim NextRow As Long, NextRow2 As Long
        Dim iRow As Long, Index As Long
        Dim mySum As Double
        iRow = 2
    
        Sheets("地块表").Activate
    
        Do While Cells(iRow, "F").Value <> ""
    
            ShtName = Cells(iRow, "F").Value
            Set Sht = Sheets(ShtName)
    
            NextRow = Sht.Range("C65536").End(xlUp).Row + 1
    
            If NextRow = 3 Then
                mySum = 0
                Index = 0
            End If
    
            Index = Index + 1
            
            If Index <= 39 Then
                Sht.Cells(NextRow, "A").Value = Cells(iRow, "A").Value    '序号
                Sht.Cells(NextRow, "C").Value = Cells(iRow, "B").Value    '农户代表
                Sht.Cells(NextRow, "G").Value = Cells(iRow, "C").Value    '地块数
                Sht.Cells(NextRow, "K").Value = Cells(iRow, "D").Value    '承包面积
            Else
                NextRow2 = Sht.Range("O65536").End(xlUp).Row + 1
                Sht.Cells(NextRow2, "O").Value = Cells(iRow, "A").Value    '序号
                Sht.Cells(NextRow2, "Q").Value = Cells(iRow, "B").Value    '农户代表
                Sht.Cells(NextRow2, "U").Value = Cells(iRow, "C").Value    '地块数
                Sht.Cells(NextRow2, "Y").Value = Cells(iRow, "D").Value    '承包面积
            End If
    
            mySum = mySum + Cells(iRow, "D").Value    '累计承包面积
            Sht.Range("Q42").Value = mySum
    
            iRow = iRow + 1
            ShtName = Cells(iRow, "F").Value
        Loop
    
        MsgBox ("ok")
    End Sub
    

      

  • 相关阅读:
    用C语言画个简单表格
    魔方阵 奇数偶数都成立
    HDU 1527 取石子游戏
    HDU 2669 Romantic
    21位花朵数(详解)
    博弈论总结(1)
    qsort排序(即快排)
    POJ 1061 青蛙的约会
    HDU 2176 取(m堆)石子游戏
    HDU1061 求n^n的最低位
  • 原文地址:https://www.cnblogs.com/nextseven/p/7248510.html
Copyright © 2011-2022 走看看