- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我不在脚本要运行的同一页面上,我会收到运行时错误 1004,我想知道原因...
这是代码。
Option Explicit
Sub PO_Tracking()
Dim wsPOD As Worksheet
Dim wsPOT As Worksheet
Dim wsPOA As Worksheet
Dim cel As Range
Dim lastrow As Long, i As Long, Er As Long
Set wsPOD = Sheets("PO Data")
Set wsPOT = Sheets("PO Tracking")
Set wsPOA = Sheets("PO Archive")
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
With wsPOD
'first bring columns F:G up to match their line
For Each cel In Intersect(.UsedRange, .UsedRange.Offset(5), .Columns(6))
If cel = vbNullString And cel.Offset(, -2) <> vbNullString Then
.Range(cel.Offset(1), cel.Offset(1, 1)).Copy cel
cel.Offset(1).EntireRow.Delete
End If
Next
'now fil columns A:D to match PO Date and PO#
For Each cel In Intersect(.UsedRange, .UsedRange.Offset(5), .Columns(1))
If cel = vbNullString And cel.Offset(, 5) <> vbNullString Then
.Range(cel.Offset(-1), cel.Offset(-1, 3)).Copy cel
End If
Next
'Blow away rows that are useless
lastrow = wsPOD.Range("A6").End(xlDown).Row
wsPOD.Range("M5:P5").Copy wsPOD.Range("M6:P" & lastrow)
Calculate
With Intersect(wsPOD.UsedRange, ActiveSheet.Columns("N"))
.AutoFilter 1, "<>Different"
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
With Intersect(wsPOD.UsedRange, ActiveSheet.Columns("P"))
.AutoFilter 1, "<>Full"
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
wsPOD.UsedRange.Copy Sheets.Add.Range("A1")
'Final Adjustments before transfering over to new sheet.
With ActiveSheet
.AutoFilterMode = False
Intersect(.UsedRange, .Columns("A")).Cut .Range("Q1")
Intersect(.UsedRange, .Columns("D")).Cut .Range("R1")
Intersect(.UsedRange, .Columns("C")).Cut .Range("S1")
Intersect(.UsedRange, .Columns("B")).Cut .Range("T1")
Intersect(.UsedRange, .Columns("G")).Cut .Range("U1")
Intersect(.UsedRange, .Columns("F")).Cut .Range("V1")
Intersect(.UsedRange, .Range("Q:V")).Copy wsPOT.Cells(Rows.Count, "B").End(xlUp).Offset(1)
.Delete
End With
lastrow = wsPOD.Cells(Rows.Count, "B").End(xlUp).Row
wsPOT.Range("R1:X1").Copy
wsPOT.Range("B3:H" & lastrow).PasteSpecial xlPasteFormats
wsPOT.Range("N2:O2").Copy wsPOT.Range("N3:O" & lastrow)
wsPOT.Range("P1:Q1").Copy wsPOT.Range("I3:J" & lastrow)
wsPOT.Range("K3:K" & lastrow).Borders.Weight = xlThin
End With
Application.CutCopyMode = False
End Sub
错误在这里:
**With Intersect(wsPOD.UsedRange, ActiveSheet.Columns("N"))**
.AutoFilter 1, "<>Different"
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
最佳答案
两个工作表上的范围不能有交集,因此如果 ActiveSheet 不是 wsPOD,则
与 Intersect(wsPOD.UsedRange, ActiveSheet.Columns("N"))
根据定义必须失败。
编辑...并查看@SiddharthRout 的修复评论。
关于excel - 运行时错误 '1004' :, 对象 'Intersect' 的方法 '_Global' 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10640397/
我参加面试的时候,面试官问了我这个问题。他们正在使用哪些内存 heap , stack 等。我用谷歌搜索但没有得到任何明确的答案。 最佳答案 好吧,既然你标记了 C,我将从它开始。 在 C 运行时,全
这可能是一个愚蠢的问题,但我在这部分 2 小时里一直被困在这个愚蠢的问题上。 我有这个函数来检查特定配置文件的变量是否不为空。这是函数:- include 'inc.config.php'; func
在这里,我试图将数据从一张表复制到另一张表,我需要从复制表中排除一个特定列 喜欢 : 认为我有 2 张来自 HSR 的工作表(名称为“组合”、“HSR”)我需要将所有数据复制到组合工作表中,不包括“D
据我所知,我已经正确声明了一切(尽管很复杂),我只需要一双新的眼睛。根据编译器,我的“MultiForm1”联合不正确: Sub ShiftMaster() 'Declarations Dim Mon
我正在使用 MS Access 和 MS Excel 来自动执行重复过程,其中我删除旧的 .csv 文件,在其位置创建一个新的 .csv 文件,用数据填充一组单元格,保存并关闭文件。以下代码在我每次执
我试图让 Excel 找出工作表的哪些列是空白的。最终的想法是让它删除完全空白的列。这是我到目前为止的代码: Sub Macro2() ' ' Macro2 Macro ' Dim totalCols
我真的是 VBA 编程的新手,我尝试编写的这段代码有问题。我希望代码找出 A 列中未使用的第一行,然后将数据从工作表的不同部分复制并粘贴到该行。 Sub CopyandPaste() Dim RowL
我正在从事一个 Foundation 5 元素,结果发现它有一个过时的 _global.scss 组件。我试图获得 range sliders工作,但他们神秘地没有。原来,我遗漏了以下 2 行 CSS
我是 VBA 新手,因为我刚刚开始学习它。 现在我在将邮件正文从 Outlook 导出到 excel 时遇到问题。有趣的是,当我第一次运行时,它就起作用了。但是当我第二次运行时,会出现我标题中所述的错
如果我不在脚本要运行的同一页面上,我会收到运行时错误 1004,我想知道原因... 这是代码。 Option Explicit Sub PO_Tracking() Dim wsPOD As Works
我在 VBA 中遇到了一个问题,其中一行抛出了错误。 宏的目的是找到一个特定的单元格,然后将数据粘贴到其中。 代码如下: 'To find Column of Customer imput For E
我尝试在存储库中搜索上述问题的解决方案,但我的 VBA 基础很初级,而且我无法找到答案。任何指导将不胜感激。 运行下面的代码时,会在以下行出错: PartNumber = Range("E" & my
试图找到一种方法将 _.global.scss 文件与我的 webpack 构建一起导入一次,而不是在每个 .scss 文件中导入它(每个组件都有一个 scss 文件)。 到目前为止,我发现的唯一可能
我不断遇到 Run-time error '1004' Method 'Range' of object '_Global' failed . 在一个名为“接收”的工作表中,我有一个具有动态名称的表(
我编写了一个 VBA 子例程(如下),该子例程应该打开给定目录中的所有 .docx 和/或 .xlsx 文件,执行查找/替换操作,然后用新文件覆盖原始文件。这对于 .xlsx 文件每次运行都会按预期工
我是一名优秀的程序员,十分优秀!