将数据从一个 sheet 复制到另一个 sheet 但在空白列中
Copy data from one sheet to another sheet but in a blank column
我有一个 sheet(我们称它为 sheet1),它会在打开时更新。所以让我们说 sheet1
我有:
a1 one
a2 two
a3 three
Sheet1
已配置为在打开时更新数据。
我希望该数据随后填充到下一个可用空白行的 Sheet2
中。因此,如果我已经在 a1-a3
中有数据,我希望将此新数据复制到 b1-b3
中,依此类推。
关于如何实现这一点有什么想法吗?
谢谢!
肯
你应该为问题提交代码,而不是为问题索取代码,但这是一个非常简单的问题。如果需要对其进行调整以满足您的需求,请尝试对其进行调整。如果您遇到困难,请提出一个新的、更具体的问题,了解如何操作或出错的原因。
无论如何,你需要一些 VBA:
Sub someVBA()
'Set the sheets we are working with - change as needed
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Worksheets("Sheet1")
Set s2 = Worksheets("Sheet2")
'Find the last column in s2 by going way out to the end of
' of the sheet and using end(xlToLeft) and adding 1 more column
' to that. That's the next blank column
Dim lastCol As Integer
lastCol = s2.Cells(1, 1000).End(xlToLeft).Column() + 1
'Copy it over
s2.Columns(lastCol).Value = s1.Columns(1).Value
End Sub
我有一个 sheet(我们称它为 sheet1),它会在打开时更新。所以让我们说 sheet1
我有:
a1 one
a2 two
a3 three
Sheet1
已配置为在打开时更新数据。
我希望该数据随后填充到下一个可用空白行的 Sheet2
中。因此,如果我已经在 a1-a3
中有数据,我希望将此新数据复制到 b1-b3
中,依此类推。
关于如何实现这一点有什么想法吗? 谢谢! 肯
你应该为问题提交代码,而不是为问题索取代码,但这是一个非常简单的问题。如果需要对其进行调整以满足您的需求,请尝试对其进行调整。如果您遇到困难,请提出一个新的、更具体的问题,了解如何操作或出错的原因。
无论如何,你需要一些 VBA:
Sub someVBA()
'Set the sheets we are working with - change as needed
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Worksheets("Sheet1")
Set s2 = Worksheets("Sheet2")
'Find the last column in s2 by going way out to the end of
' of the sheet and using end(xlToLeft) and adding 1 more column
' to that. That's the next blank column
Dim lastCol As Integer
lastCol = s2.Cells(1, 1000).End(xlToLeft).Column() + 1
'Copy it over
s2.Columns(lastCol).Value = s1.Columns(1).Value
End Sub