Vba 将内容从一张工作表复制到另一张工作表时出错

Vba 将内容从一张工作表复制到另一张工作表时出错,vba,excel,Vba,Excel,我正在尝试将工作表CurrentDistribution与工作表distribution1连接起来。为此,我查看distribution1的最后一行,并将CurrentDistribution的内容复制到最后一行之后 LastCellCurrentDistribution = FindLastCell(CurrentDistribution) LastCellDistribution1 = FindLastCell("distribution1") LastRowInDistribution1

我正在尝试将工作表
CurrentDistribution
与工作表
distribution1
连接起来。为此,我查看
distribution1
的最后一行,并将
CurrentDistribution
的内容复制到最后一行之后

LastCellCurrentDistribution = FindLastCell(CurrentDistribution)
LastCellDistribution1 = FindLastCell("distribution1")
LastRowInDistribution1 = Right(LastCellDistribution1, Len(LastCellDistribution1) - 1)
Sheets(CurrentDistribution).Range("A4:" + LastCellCurrentDistribution).Copy Sheets("distribution1").Range("A" + CStr((CInt(LastRowInDistribution1) + 1))) 'i only wany the row (number), not the column (letter)
Sheets(CurrentDistribution).Delete

现在的问题是,当我尝试执行此操作时,会出现以下错误:
'Run-timeerror'6':Overflow'
。我使用了调试器,发现它的第4行复制了抛出此错误的内容。知道问题出在哪里吗?我想只要整数不能处理大于32000的值,就需要声明变量
LastCellCurrentDistribution
LastCellDistribution1
LastRowInDistribution1

试着像下面这样声明它们:

Dim LastCellCurrentDistribution As Long
Dim LastCellDistribution1 As Long
Dim LastRowInDistribution1 As Long

看起来我的工作表太大了,INT-type无法处理我的最后一个单元格编号。因此,请替换:

Sheets(CurrentDistribution).Range("A4:" + LastCellCurrentDistribution).Copy Sheets("distribution1").Range("A" + CStr((CInt(LastRowInDistribution1) + 1))) 'i only wany the row (number), not the column (letter)

Sheets(CurrentDistribution).Range("A4:" + LastCellCurrentDistribution).Copy Sheets("distribution1").Range("A" + CStr(LastRowInDistribution1 + 1)) 'i only wany the row (number), not the column (letter)