如何解决“运行时错误1004.为此,所有合并的单元格需要大小相同”

时间:2014-02-28 17:54:46

标签: excel excel-vba runtime-error vba

希望复制C22:O22范围内的值,然后将其粘贴到cells(9,11)中定义的行数中。

我一直收到错误Run-time error 1004. To do this, all the merged cells need to be the same size

不确定这意味着什么。

 Sub Button1_Click()
      Dim Ncopy As Integer
      Dim Nfloors As Integer
      Dim Part1 As Range
      'Set Nfloors equal to the number of floors in cell K9
      Nfloors = Cells(9, 11).Value
      'Set Ncopy equal to the number of total rows in the final table. (Nfloors+1)
      Ncopy = Nfloors + 1
      'Define the final table size (table final row, table final column)
      Set Part1 = Cells(Ncopy, 15)
      'Select the range of cells to be copied
      Range("C22:O22").Select
      'Create the full table and fill with copied cell formulas
      Selection.AutoFill Destination:=Range("C22", Part1), Type:=xlFillDefault
      'Select and unused cell to end the routine
      Range("B3").Select
 End Sub

0 个答案:

没有答案