范围复制不复制?

时间:2019-02-08 20:54:00

标签: excel vba

在输入所需的工作表数量后,我试图将用作模板的单元格范围复制到新工作表中。我能够根据需要创建/删除工作表,但是由于某些原因,范围复制实际上并未复制(但是源和范围本身似乎是有效的。Sample is located here,谢谢!下面也是相关代码< / p>

xOffset = Sheets("Initial Estimate").index 'initial sheet
Set xActiveSheet = Sheets(xOffset)   'sheet is not first tab

xNumber = Worksheets("Initial Estimate").Range("$B$1").Value 'input value
 For I = 1 To xNumber Step 1

        CheckSheetName = "" 'clear checkname or else get false positives

       xName = "Estimated Invoice 0" + CStr(I)

    CheckSheetName = Worksheets(xName).Name

    If CheckSheetName = "" Then 'doesnt exist

        Worksheets.Add(After:=Sheets(Sheets.Count)).Name = xName
        CheckSheetName = Worksheets(xName).Name

        MsgBox "inside " + CheckSheetName 'exists here, so should be able to copy right?

      xActiveSheet.Range("A17:H34").Copy Destination:=Worksheets(xName).Range = ("A1")   ' copy initial sheet range to xName sheet

    End If

Next I

0 个答案:

没有答案