在工作簿打开时,自动将工作表之间的行复制到最后一行

我已经尝试了两个星期的时间来编写一个能够完成以下工作的代码:将工作表“时间卡”的前21行复制并插入到同一工作表底部的第一个空白行中“时间卡“。 我也希望,一旦行被复制,将包含selectdate的单元格(在表单的底部)进行select,以便用户不必向下滚动6500行。

代码将不得不select工作表(“时间卡”),复制selectC3:N23,并将select粘贴到工作表底部的最后一个和第一个空白行(“时间卡”)。 然后,必须自动select存储“date”的单元格(在刚刚粘贴的select内)(编写代码以search“date”范围?)。 一旦完成,我想要一个代码,链接到一个macrosbutton,用户可以单击以清除数据validation,以便只有公式保留在新粘贴的单元格中,所有的VLOOKUPS和数据validation已被清除。

请,请有人请请帮我写一个代码。 我真的做了很多的研究,尝试了几种不同的方法,并没有能够做任何工作。 我不是很熟练的VBA,所以任何帮助将不胜感激。

这是我第一次尝试:

Sub CopyInfo() On Error GoTo Err_Execute Sheets("Time Cards").Select Cells(Rows.Count, ActiveCell.Column).End(xlUp).Offset(1, 0).Select Sheets("TC-Start Here").Select Range("C5:N25").Select Selection.Copy Sheets("Time Cards").Select 'Range("C5:N25").Select Selection.Insert Err_Execute: MsgBox "The Data has been successfully Copied" End Sub 

然后我试着select最后一行并粘贴(第二次尝试):

 Sub CopyInfo() On Error GoTo Err_Execute Sheets("Time Cards").Select Cells(Rows.Count, ActiveCell.Column).End(xlUp).Offset(1, 0).Select Sheets("TC-Start Here").Select Range("C5:N25").Select Selection.Copy Sheets("Time Cards").Select Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0).Select Selection.Insert Shift:=xlDown Sheets("Time Cards").Select 'Range("C5:N25").Select Selection.Insert Err_Execute: MsgBox "The Data has been successfully Copied" End Sub 

它似乎没有工作,我永远不能得到它select包含date的细胞,也不清除validation。

我认为这是你想要的,如果不是,请进一步澄清你的问题

  Dim lrow as long lrow = sheets("time cards").range("C5").end(xlup).row + 1 sheets("TC-Start Here").range("C5:N25").copy sheets("time cards").range("C" & lrow).pastespecial paste:=xlpastevalues, _ operation:=xlnone, _ skipblanks:=False, _ Transpose:=false sheets("time cards").range("C5").end(xlup).select 
 Sub CopyInfo() With Sheets("Time Cards") .Range("C5:N25").Copy .Cells(Rows.Count,3).End(xlUp).Offset(1, 0) .Cells(Rows.Count,3).End(xlUp).Select End With 'need some info on exactly what should be cleared from the copied range... MsgBox "The Data has been successfully Copied" End Sub