» 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
Question: 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:
- Microsoft Office Xp: Advanced Concepts and Techniques: Word 2002, Excel 2002, Access 2002, Powerpoint 2002
- Accounting Principles, with CD, 6th Edition
- Quantitative Methods in Derivatives Pricing: An Introduction to Computational Finance
- The Interpretation of Financial Statements
- Microsoft Office XP Introductory Concepts and Techniques
- The Essential 55: An Award-Winning Educator's Rules for Discovering the Successful Student in Every Child
No comments have been submitted.

