2012-03-28 116 views
-1

我需要找到一个脚本,允许我使用工作簿中索引表中的信息。Excel工作表单元格到不同工作表

  • 我需要它从范围A3:G304获取数据。
  • 数据将分散到各自的工作表中。
  • 这些图纸是针对列A中的值命名的,需要将其放置在单元格中,如下面的A到A1; B到A2; C到A3; D到B3; E至C3; F到E2; G到G2。
  • 每一行对应一张不同的纸张。

预先感谢您

+0

您是否尝试过“细胞”和“间接”? – RobinGower 2012-03-28 16:06:20

回答

0

以下是你需要的代码:

Dim targetSheet As Worksheet 
Dim rowIndex, columnCount As Integer 

Set targetSheet = ActiveSheet 
columnCount = UBound(initialRange, 2) 


For rowIndex = 3 To 304 
    Set targetSheet = Sheets.Add(After:=targetSheet) 
    ' The (Row #) is added to sheet name to prevent Workbook from having duplicated name sheets 
    ' Remove if not applicable 
    targetSheet.Name = Cells(rowIndex, "A").Value & " (Row " & rowIndex & ")" 

    Cells(rowIndex, "A").Resize(1, 7).Copy 
    targetSheet.Cells(columnCount, "A").End(xlUp).PasteSpecial Transpose:=True 
    Application.CutCopyMode = False 
Next rowIndex 

唯一的问题是,Excel将可能有超过300个工作表用完ressources的。

相关问题