» Move row into worksheet after entry of worksheet name into row using VBA in Microsoft Excel
CATEGORY - Cells, Ranges, Rows, and Columns in VBA
VERSION - All Microsoft Excel Versions
When entering a sheet name in column D, the row of the entry is to be moved to the respective sheet
Answer:
Insert the following code in the This Workbook module.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wks As Worksheet
Dim intRow As Integer
If Target.Column <> 4 Then Exit Sub
If IsEmpty(Target) Then Exit Sub
On Error Resume Next
Set wks = Worksheets(Target.Value)
If Err > 0 Or wks Is Nothing Then
MsgBox "Sheet name Not Found!"
Exit Sub
End If
On Error GoTo 0
With wks
intRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Range(.Cells(intRow, 1), .Cells(intRow, 3)).Value = _
Range(Cells(Target.Row, 1), Cells(Target.Row, 3)).Value
End With
Rows(Target.Row).Delete
End Sub
Book Store:
No comments have been submitted.

