需要复制上一行的公式以自动填充。
destsht("All PO Raw Data 1-18").Columns("V3:X" & destLR).FillDown
Dim wb As Workbook
Dim sht As Worksheet, destsht As Worksheet
Dim destLR As Long, LastRow As Long
Set wb = ThisWorkbook
Set sht = wb.Sheets("Open PO Raw Data")
Set destwb = Workbooks.Open("C:\Users\rc\Desktop\ALL PO RAW DATA 1-18 to present_copy.xlsx")
Set destsht = destwb.Sheets("All PO Raw Data 1-18")
destLR = destsht.Cells(Rows.Count, "A").End(xlUp).Row + 1
MsgBox destLR
wb.ActiveSheet.Activate
LastRow = sht.Cells(Rows.Count, "A").End(xlUp).Row
sht.Range("A2:U" & LastRow).SpecialCells(xlCellTypeVisible).Copy destsht.Range("A" & destLR)
destsht("All PO Raw Data 1-18").Columns("V3:X" & destLR).FillDown
公式向下移动到最后一行。代码的最后一行给了我错误。我收到438错误讯息。对象不支持该属性。我想我可能需要一个偏移量而不是V3中显示的内容。
答案 0 :(得分:0)
在粘贴可见单元格后,我不得不修改代码以对行进行计数。现在,它一直向下复制。
将wb视作工作簿 昏暗作为工作表,desshtht作为工作表 昏暗的destLR一样长,LastRow一样长
设置wb = ThisWorkbook 设置sht = wb.Sheets(“ Open PO Raw Data”)
设置destwb = Workbooks.Open(“ C:\ Users \ rc \ Desktop \ ALL PO RAW DATA 1-18 to present.xlsx”) 设置destsht = destwb.Sheets(“所有采购订单原始数据1-18”) destLR = destsht.Cells(Rows.Count,“ A”)。End(xlUp).Row + 1 'MsgBox destLR
wb.ActiveSheet.Activate LastRow = sht.Cells(Rows.Count,“ A”)。End(xlUp).Row sht.Range(“ A2:U”&LastRow).SpecialCells(xlCellTypeVisible).Copy destsht.Range(“ A”&destLR)
Number_of_Rows = sht.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count-1 'MsgBox Number_of_Rows
destLR = destLR +行数 'MsgBox destLR
destsht.Range(“ V3:X”&destLR).FillDown