简体   繁体   English

1004全局错误-Excel VBA

[英]1004 Global Error - Excel VBA

My code doesn't work. 我的代码不起作用。 I want to do A2 + 1 = A3 in macros, but when I tried to using p as integer, it gives me 1004 Global Error . 我想在宏中执行A2 + 1 = A3 ,但是当我尝试使用p作为整数时,它给了我1004 Global Error How to do (n,1) A2 + 1 = A3 in Excel VBA? 如何在Excel VBA中执行(n,1) A2 + 1 = A3

Sub agregarproducto()

Range("A7:G7").Select
Range("G7").Activate
Selection.Copy

Dim p As Integer

p = 0
p = Range("A2:A50").Count
p = p + 1

Range(p, 1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

    Range("E2:E3").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("L11").Select
    ActiveCell.FormulaR1C1 = "1"

End Sub

Change 更改

Range(p, 1).Select

to

Cells(p, 1).select

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM