VBA复制行高?

我有一个电子表格在Excel 2003中(保存为一个macros启用2007年.xlsm电子表格),它使用查询从SQL获取数据。 我将电子表格设置为只读,以便用户不会搞乱我的工作,并使用以下代码将主电子表格中的值复制到新电子表格

Sub NewWB() Dim wbNew As Workbook Dim wbThis As Workbook Dim rng As Range Dim wbName As String Dim Pic As Picture wbName = ThisWorkbook.Name Set wbThis = Application.Workbooks(wbName) Set rng = wbThis.Worksheets("Report").Range("C1:AZ65336") Set wbNew = Workbooks.Add(xlWBATWorksheet) Set Pic = wbThis.Worksheets("Report").Pictures("Picture 2") With Pic With .ShapeRange .ScaleHeight 1#, msoScaleFromTopLeft .ScaleWidth 1#, msoScaleFromTopLeft End With End With rng.Copy With wbNew .Worksheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats .Worksheets(1).Range("A1").PasteSpecial Paste:=8 .Worksheets(1).Range("A1").PasteSpecial xlPasteFormats Pic.Copy .Worksheets(1).Paste .SaveAs Filename:=wbThis.Path & "\" & Left(wbName, InStr(wbName, ".") - 1) & _ Format(Date, "_yyyy-mm-dd"), _ FileFormat:=xlWorkbookNormal End With ' wbThis.Close End Sub 

它有一个小问题很好。 它不会复制我的行高,所以我复制的标志最终覆盖了部分数据! 似乎令人难以置信的是,有一种方法可以直接复制列,但没有办法复制行。

我需要做些什么才能使行高被复制,我正在处理文档的前100行。

我做了两个新的variables

 Dim rngNew as Range Dim x As Integer 

并编辑我的“与wbNew”部分有以下代码

  With wbNew .Worksheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats 'Paste only the values and how the values are formatted .Worksheets(1).Range("A1").PasteSpecial Paste:=8 ' Paste the column widths .Worksheets(1).Range("A1").PasteSpecial xlPasteFormats ' Paste cell formats (boarders, colors, etc) x = 1 For Each rngNew In .Worksheets(1).Range("A1:A100") ' Set the range in the new worbook rngNew.EntireRow.RowHeight = wbThis.Worksheets("Report").Range("A" & CStr(x)).RowHeight 'Each row in the new workbook equals the equivilant row in the first workbook x = x + 1 Next Pic.Copy ' Copy the logo .Worksheets(1).Paste ' Paste the Logo .SaveAs Filename:=wbThis.Path & "\" & Left(wbName, InStr(wbName, ".") - 1) & _ Format(ReportDate, "_yyyy-mm-dd"), _ FileFormat:=xlWorkbookNormal ' Save the workbook as a generic .xls End With 

它比我所希望的更粗糙,它使用了我从第一行开始的假设(这对我正在做的事情是很好的),但它的作用是阻止更好的答案。