PC Review


Reply
Thread Tools Rate Thread

Copy Code and a sort problem

 
 
BillD
Guest
Posts: n/a
 
      20th Oct 2009
I have a workbook with 5 sheets. Sheet 1 is my index sheet which lists upto
60 employees. The other 4 sheets are scheduling sheets. My situation is I
want to be able to copy the index sheet 4 columns and 60 rows from the index
to all 4 of my worksheets, and if possible I would like the updates to run
automatically either when I hit the enter key or click on the mouse. The main
problem I am having is I want to devide the index (4 columns 60 rows) into
three sets of columns with 4 columns and 20 rows so I can view all of the
employee names on one screen. Below is the code I have come up with from
reading other discussion threads so I don't know if it is right or not.
Please advise any changes and what I need to do to have the worksheets update
as I enter the data.
My other question is do you know if when I sort the index (after making
changes) will the other worksheets sort the data into the right order or can
that not be done with the index split into three groups.
Here is what I would like to have:
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13
14 15 16
5 6 7 8
9 10 11 12
13 14 15 16

Here is the code I have now which works but does not run automatically. The
code is stored in Sheet1

Sub CopyRanges()
'
' Test_cop_2 Macro
' Macro recorded 10/20/2009 by
'

'
Range("A2039").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A2039").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("A2039").Select
ActiveSheet.Paste
Sheets("Sheet4").Select
Range("A2039").Select
ActiveSheet.Paste
Sheets("Sheet5").Select
Range("A2039").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("A4059").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("F20:I39").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("F20:I39").Select
ActiveSheet.Paste
Sheets("Sheet4").Select
Range("F20:I39").Select
ActiveSheet.Paste
Sheets("Sheet5").Select
Range("F20:I39").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=24
Range("A6079").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("K20:N39").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("K20:N39").Select
ActiveSheet.Paste
Sheets("Sheet4").Select
Range("K20:N39").Select
ActiveSheet.Paste
Sheets("Sheet5").Select
Range("K20:N39").Select
ActiveSheet.Paste
End Sub

--
BillD
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      20th Oct 2009
Put this in the Sheet1 Module. I have the copy and destination all in one
line when I copied it.

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("A2039")) Is Nothing Then
Me.Range("A2039").Copy Destination:=Sheets("sheet2").Range("A2039")
Me.Range("A2039").Copy Destination:=Sheets("sheet3").Range("A2039")
Me.Range("A2039").Copy Destination:=Sheets("sheet4").Range("A2039")
Me.Range("A2039").Copy Destination:=Sheets("sheet5").Range("A2039")
End If

If Not Intersect(Target.ME.Range("A4059")) Is Nothing Then
Me.Range("A4059").Copy Destination: Sheets("Sheet2").Range ("A4059")
Me.Range("A4059").Copy Destination: Sheets("Sheet2").Range ("A4059")
Me.Range("A4059").Copy Destination: Sheets("Sheet2").Range ("A4059")
Me.Range("A4059").Copy Destination: Sheets("Sheet2").Range ("A4059")
End If

If Not Intersect(Target, Me.Range("a60:d79")) Is Nothing Then
Me.Range("A6079").Copy Destination: Sheets("Sheet2").Range ("K20:N39")
Me.Range("A6079").Copy Destination: Sheets("Sheet2").Range ("K20:N39")
Me.Range("A6079").Copy Destination: Sheets("Sheet2").Range ("K20:N39")
Me.Range("A6079").Copy Destination: Sheets("Sheet2").Range ("K20:N39")




End Sub


HTH,
Barb Reinhardt


"BillD" wrote:

> I have a workbook with 5 sheets. Sheet 1 is my index sheet which lists upto
> 60 employees. The other 4 sheets are scheduling sheets. My situation is I
> want to be able to copy the index sheet 4 columns and 60 rows from the index
> to all 4 of my worksheets, and if possible I would like the updates to run
> automatically either when I hit the enter key or click on the mouse. The main
> problem I am having is I want to devide the index (4 columns 60 rows) into
> three sets of columns with 4 columns and 20 rows so I can view all of the
> employee names on one screen. Below is the code I have come up with from
> reading other discussion threads so I don't know if it is right or not.
> Please advise any changes and what I need to do to have the worksheets update
> as I enter the data.
> My other question is do you know if when I sort the index (after making
> changes) will the other worksheets sort the data into the right order or can
> that not be done with the index split into three groups.
> Here is what I would like to have:
> 1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13
> 14 15 16
> 5 6 7 8
> 9 10 11 12
> 13 14 15 16
>
> Here is the code I have now which works but does not run automatically. The
> code is stored in Sheet1
>
> Sub CopyRanges()
> '
> ' Test_cop_2 Macro
> ' Macro recorded 10/20/2009 by
> '
>
> '
> Range("A2039").Select
> Selection.Copy
> Sheets("Sheet2").Select
> Range("A2039").Select
> ActiveSheet.Paste
> Sheets("Sheet3").Select
> Range("A2039").Select
> ActiveSheet.Paste
> Sheets("Sheet4").Select
> Range("A2039").Select
> ActiveSheet.Paste
> Sheets("Sheet5").Select
> Range("A2039").Select
> ActiveSheet.Paste
> Sheets("Sheet1").Select
> Range("A4059").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet2").Select
> Range("F20:I39").Select
> ActiveSheet.Paste
> Sheets("Sheet3").Select
> Range("F20:I39").Select
> ActiveSheet.Paste
> Sheets("Sheet4").Select
> Range("F20:I39").Select
> ActiveSheet.Paste
> Sheets("Sheet5").Select
> Range("F20:I39").Select
> ActiveSheet.Paste
> Sheets("Sheet1").Select
> ActiveWindow.SmallScroll Down:=24
> Range("A6079").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet2").Select
> Range("K20:N39").Select
> ActiveSheet.Paste
> Sheets("Sheet3").Select
> Range("K20:N39").Select
> ActiveSheet.Paste
> Sheets("Sheet4").Select
> Range("K20:N39").Select
> ActiveSheet.Paste
> Sheets("Sheet5").Select
> Range("K20:N39").Select
> ActiveSheet.Paste
> End Sub
>
> --
> BillD

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Sort Unique Problem cranen Microsoft Excel Misc 5 26th Aug 2009 11:00 PM
copy and paste code problem =?Utf-8?B?YmlnZGFkZHkz?= Microsoft Excel Worksheet Functions 10 21st Sep 2005 05:55 PM
Pls. reply Sort Data and copy to next coulmn when sort order chang =?Utf-8?B?c2hpdGFsIHNoYWg=?= Microsoft Excel Programming 0 19th Aug 2005 10:29 AM
Zip code sort is an Excel problem even when using the special cat. =?Utf-8?B?Y2FtZWFk?= Microsoft Excel Misc 2 31st Mar 2005 01:15 AM
how to sort a table in code, something like rs.sort = "GroupNumber =?Utf-8?B?TmV3YmVlIEFkYW0=?= Microsoft Access Getting Started 2 8th Mar 2005 05:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:21 AM.