偏移问题从一个WS移动到另一个WS
我只是试图将一些信息从列将其移至另一张列的另一列,然后使用偏移将其从我需要开始的行开始。试图不使用.popy或.cut或任何类型。
with ws
ecol = .cells(7,.columns,count).end(xltoleft).column
.columns(ecol) = ws2.column("AB").Value2
end with
这有效。只是将其放置在错误的区域。因此,尝试使用偏移量无论如何我都会收到1004错误
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(ecol).offset(7,0) = ws2.column("AB").Value2
end with
错误1004
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(ecol).offset(7) = ws2.column("AB").Value2
end with
错误1004
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(7, ecol) = ws2.column("AB").Value2
end with
我怀疑这是因为它将整个AB列从第1行将整个AB列拉到1MM++,而我无法更改范围。
无论哪种方式,我都希望对此进行一些帮助。我正在WS2上使用动态范围。我认为也许我可以使用.end(XLUP)。行程找到底部行并调整语法,但仍然会遇到相同的错误,或者我只是不知道如何编写它。
任何帮助都将受到赞赏。
I'm simply trying to move some information from a column to another column on another sheet and using offset to get it to start on the row i need it to start on. trying to not use .copy or .cut or any of the sort.
with ws
ecol = .cells(7,.columns,count).end(xltoleft).column
.columns(ecol) = ws2.column("AB").Value2
end with
this works. just places it in the wrong area. so trying to use offset in anyway i'm getting 1004 error
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(ecol).offset(7,0) = ws2.column("AB").Value2
end with
Error 1004
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(ecol).offset(7) = ws2.column("AB").Value2
end with
Error 1004
with ws
ecol = .cells(7, .columns.count).end(xltoleft).column
.columns(7, ecol) = ws2.column("AB").Value2
end with
i suspect maybe it's because it's pulling the entire AB column from row 1 to 1mm+ and i just can't change the range.
either way i'd like some help tweaking this. i'm working with a dynamic range on ws2. i thought maybe i could use .end(xlup).row to find the bottom row and adjust the syntax but still getting the same error or i just don't know how to write it.
any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您对整个列转移是正确的。此代码将尽可能多地传输列的大部分。
您可能需要将其限制为仅在有数据的地方传输,但这取决于您!
希望它有帮助
I think you were right about the whole column transfer. This code transfers as much of the column as possible.
you may want to restrict this to only transferring where there is data but thats up to you!
hope it helps