When I enter an amount into the A column, move a group of cells in that row
to another sheet in Excel.
Put this code into the worksheet's code section - not the workbook or a
general module. I set up variables so you can provide the name of the sheet
that the information is to be copied to and specify the columns in the row to
be copied.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim SourceSheetName As String
Dim DestinationSheetName As String
Dim StartColumnForCopy As String
Dim EndColumnForCopy As String
Dim AnyRange As String
SourceSheetName = ActiveSheet.Name ' save this sheet name
'change as needed
DestinationSheetName = quot;Sheet2quot; ' change as required
StartColumnForCopy = quot;Bquot;
EndColumnForCopy = quot;Equot;
'end of user needed changes
If Target.Column lt;gt; 1 Then ' was not in column A
Application.EnableEvents = True
Exit Sub
End If
Application.EnableEvents = False
Application.ScreenUpdating = False
AnyRange = StartColumnForCopy amp; Target.Row amp; quot;:quot; _
amp; EndColumnForCopy amp; Target.Row
Range(AnyRange).Select
Selection.Copy
ThisWorkbook.Sheets(DestinationSheetName).Activate
ActiveSheet.Range(AnyRange).Select
ActiveSheet.Paste
Sheets(SourceSheetName).Select
Range(Target.Address).Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
quot;Jay95quot; wrote:
gt; When I enter an amount into the A column, move a group of cells in that row
gt; to another sheet in Excel.
- Mar 09 Fri 2007 20:36
when I enter an amount in the A column move the row to another she
close
全站熱搜
留言列表
發表留言