» 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:
Recommended Books:
- Personal Finance for Dummies
- Who Moved My Cheese? An Amazing Way to Deal with Change in Your Work and in Your Life
- Keys to Reading an Annual Report (Barron's Business Keys)
- AWAKEN THE GIANT WITHIN : HOW TO TAKE IMMEDIATE CONTROL OF YOUR MENTAL, EMOTIONAL, PHYSICAL AND FINANCIAL
- The 22 Immutable Laws of Marketing : Exposed and Explained by the World's Two
- Retire Young, Retire Rich
No comments have been submitted.


