ChuckRobert
Board Regular
- Joined
- Feb 26, 2009
- Messages
- 64
I have a Personnel Worksheet that is automatically sorted by Hire Date when the worksheet tab ("Hire Date") is clicked. This works well.
I am trying to display the same data on another sheet, sorted by last name when the worksheet tab ("Last Name") is clicked. Many other worksheets will refererence this sheet for sorted names.
I have been trying to do this by copying the data from ("Hire Date") and pasting it in ("Last Name") from View Code Activate for ("Last Name"), but I get a run-time error '1004' Select method of Range class failed for trying to copy the data from ("Hire Date").
Here is the code I am using in the worksheet tab for ("Last Name") - view code - on activate -
Private Sub Worksheet_Activate()
ActiveSheet.Unprotect Password:="password"
Cells.Select
Range("B1").Activate
Selection.Delete Shift:=xlUp
Range("F1").Select
Sheets("Hire Date").Activate
ActiveSheet.Unprotect Password:="password"
Columns("C:Q").Select
Selection.Copy
When I run by clicking the ("Last Name") tab, I get a run-time error '1004' Select method of Range class failed. The entry "Columns("C:Q").Select is in Yellow when de-bugging.
I have tried Sheets("Hire Date").Select, then activate, but I can't figure this out. Nothing is hidden - no merged cells. The copy/paste works fine if I run it from a macro, but the workbook name changes every week so I'm not sure how I could reference an Application.Run in the worksheet tab. If I replace my Tab name ("Hire Date") for the sheet name ("Sheet35") it displays "Subscript out of range".
Perhaps there is a more efficient way to do this?
I am trying to display the same data on another sheet, sorted by last name when the worksheet tab ("Last Name") is clicked. Many other worksheets will refererence this sheet for sorted names.
I have been trying to do this by copying the data from ("Hire Date") and pasting it in ("Last Name") from View Code Activate for ("Last Name"), but I get a run-time error '1004' Select method of Range class failed for trying to copy the data from ("Hire Date").
Here is the code I am using in the worksheet tab for ("Last Name") - view code - on activate -
Private Sub Worksheet_Activate()
ActiveSheet.Unprotect Password:="password"
Cells.Select
Range("B1").Activate
Selection.Delete Shift:=xlUp
Range("F1").Select
Sheets("Hire Date").Activate
ActiveSheet.Unprotect Password:="password"
Columns("C:Q").Select
Selection.Copy
When I run by clicking the ("Last Name") tab, I get a run-time error '1004' Select method of Range class failed. The entry "Columns("C:Q").Select is in Yellow when de-bugging.
I have tried Sheets("Hire Date").Select, then activate, but I can't figure this out. Nothing is hidden - no merged cells. The copy/paste works fine if I run it from a macro, but the workbook name changes every week so I'm not sure how I could reference an Application.Run in the worksheet tab. If I replace my Tab name ("Hire Date") for the sheet name ("Sheet35") it displays "Subscript out of range".
Perhaps there is a more efficient way to do this?