excel - 从上一行向下复制公式
问题描述
需要从上一行复制公式以自动填充。
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 显示的内容。
解决方案
在粘贴可见单元格后,我不得不修改我的代码来计算行数。现在它一直向下复制。
将 wb 调暗为工作簿 将 sht 调为工作表,将 destsht 调为工作表 将 destLR 调暗,只要 LastRow
Set wb = ThisWorkbook Set sht = wb.Sheets("打开 PO 原始数据")
Set destwb = Workbooks.Open("C:\Users\rc\Desktop\ALL PO RAW DATA 1-18 to present.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)
Number_of_Rows = sht.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1 ' MsgBox Number_of_Rows
destLR = destLR + Number_of_Rows 'MsgBox destLR
destsht.Range("V3:X" & destLR).FillDown
推荐阅读
- javascript - 如何增量切片数组
- php - 单个雄辩关系的多个表
- swift - Firestore 数据库和存储问题
- flatbuffers - flatbuffers 中标头的用途是什么?
- javascript - 如何使vuejs点击事件同步
- javascript - 如何在 c++ 中创建对象类型,如 javascript 中的对象类型
- python - Python Selenium 将数据 ID 和数据名称保存在文件中
- python - Selenium WebDriverException:无法访问 chrome
- permissions - 使用 CLI 或 API 授予对 Databricks 作业的查看权限
- excel - DAX日历动态假期功能