我正在尝试修复代码,以防止我的复制粘贴覆盖其中包含值的单元格。现在,我已经创建了一个用户窗体,老板可以使用它更轻松地使用分配类。谁能帮助我更改此代码,使其仅粘贴在空白单元格中?
下面的代码读取日期并将其选择为活动单元格。然后,我希望它偏移到C列并将信息从“课程”工作表粘贴到活动工作表。大家随时可以腾出的时间将不胜感激。
Private Sub ContinueMG_Click()
Dim rfoundCell As Range, SrchRng As Range
On Error Resume Next
MGSch.Hide
Set rfoundCell = ActiveSheet.Range("A7:A750").Find(What:=DateValue(MGDate.Value), LookIn:=xlValues)
If Not rfoundCell Is Nothing Then
rfoundCell.Select
Else
MsgBox "Date was not found. Please try again."
Exit Sub
End If
Select Case MGCourse.Value
Case "Course 1"
Select Case MGCourseSlect.Value
Case "Course1"
Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 3)) = Worksheets("Courses").Range("V2:W2").Value
ActiveCell.Offset(0, 4) = MGRoom.Value
Range(ActiveCell.Offset(0, 14), ActiveCell.Offset(0, 15)) = Worksheets("Courses").Range("X2:Y2").Value
Case "Course2"
Range(ActiveCell.Offset(0, 6), ActiveCell.Offset(0, 7)) = Worksheets("Courses").Range("V2:W2").Value
ActiveCell.Offset(0, 8) = MGRoom.Value
Range(ActiveCell.Offset(0, 16), ActiveCell.Offset(0, 17)) = Worksheets("Courses").Range("X2:Y2").Value
End Select
Case ""
MsgBox "No course was selected. Please try again."
End Select
Application.CutCopyMode = False
Unload Me
End Sub