[英]VBA - Copy cell and paste into an empty cell on another sheet
I'm new to VBA so please bear with me. 我是VBA的新手,请多多包涵。 I was wondering if someone could help me please with an issue I am experiencing.
我想知道是否有人可以帮助我解决我遇到的问题。 Can someone help me copy the cell V10 in a sheet named "Standard_NewSale_GSS" and paste into the next available empty cell in the Column E in the "Standard_Basket" sheet.
有人可以帮我在名为“ Standard_NewSale_GSS”的工作表中复制单元格V10,然后粘贴到“ Standard_Basket”工作表的E列中的下一个可用空单元格中。 If anyone can help it would be very much appreciated!
如果有人可以帮助,将不胜感激! It's for my coursework at college.
这是我在大学的课程。
If you wish to hardcode these values into your subroutine, you could do something like the following: 如果希望将这些值硬编码到子例程中,则可以执行以下操作:
Option Explicit
Sub CopyIntoStandardBasketColumnE()
Dim nextCellInColumn As Range
Set nextCellInColumn = Worksheets("Standard_Basket").Cells(Rows.Count, 5).End(xlUp).Offset(1, 0)
nextCellInColumn.Value = Worksheets("Standard_NewSale_GSS").Range("V10").Value
End Sub
This finds the last cell of column E
in Worksheets("Standard_Basket")
by starting at the last row of the worksheet and using End(xlUp)
to find a cell with a value. 这将从工作表的最后一行开始,并使用
End(xlUp)
查找具有值的单元格,从而找到Worksheets("Standard_Basket")
E
列的最后一个单元格。 Then it uses Offset
to move to the next row. 然后,它使用“
Offset
移动到下一行。 Finally it sets this cell's value to be equal to cell V10
of Worksheets("Standard_NewSales_GSS")
. 最后,它将此单元格的值设置为等于
Worksheets("Standard_NewSales_GSS")
单元格V10
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.