- 日志
- 好友
- 卖家信用

- 买家信用

- 注册时间
- 2011-3-31
- 在线时间
- 小时
|
发表于 2011-11-29 22:33:00
|
显示全部楼层
还是不大明白你想做什么,Descolumncount又是什么?参数?
表头位置怎么找,非空字符算吗?
随便写了个function,不知道你想要怎么样的。参数是3张sheet的sheet名和你的Descolumncount。。。
Function dosheet(sheet1 As String, sheet2 As String, sheet3 As String, descount As Integer)
Dim StartRow, StartCol, EndRow, EndCol, tmpr, tmpc As Integer
EndRow = Sheets(sheet1).Cells.SpecialCells(xlLastCell).Row
EndCol = Sheets(sheet1).Cells.SpecialCells(xlLastCell).Column
'找表头。。。
For tmpr = 1 To EndRow
For tmpc = 1 To EndCol
If Trim(Sheets(sheet1).Cells(tmpr, tmpc)) <> "" Then
StartRow = tmpr + 1
StartCol = tmpc
tmpr = EndRow + 1
tmpc = EndCol + 1
End If
Next
Next
'COPY表头
For tmpc = StartCol To EndCol
Sheets(sheet3).Cells(StartRow - 1, tmpc) = Sheets(sheet1).Cells(StartRow - 1, tmpc)
Next
For tmpr = StartRow To EndRow
For tmpc = StartCol To EndCol
'descount-1为止相乘
If tmpc < descount Then
Sheets(sheet3).Cells(tmpr, tmpc) = Sheets(sheet1).Cells(tmpr, tmpc) * Sheets(sheet2).Cells(tmpr, tmpc)
Else
'其他COPY
Sheets(sheet3).Cells(tmpr, tmpc) = Sheets(sheet1).Cells(tmpr, tmpc)
End If
Next
Next
End Function
|
评分
-
查看全部评分
|