Austinhead
New Member
- Joined
- May 13, 2010
- Messages
- 24
Hi Guys,
I have already had some great help on this forum, but once again I am stuck and am hoping someone can help me.
I have a spreadsheet with multiple worksheet names, I want to copy some data across from e.g. the last 5 worksheet to the first 5 worksheets. The complication is that the worksheet names for the first 5 can change (U2-A01 up to U2-A010, or U3-A01 up to U3-A010 e.t.c.) and each spreadsheet can have up to 20 worksheets.
Rather than having to change the macro each time, I was hoping to use the LIKE operator to find the appropriate worksheet to copy to. I cannot get this working, but that's not surprising since my macro knowledge is very very poor.
The code is below:
Sub Copy_Objectives()
Dim sh As Variant
'
'
' Copies objectives from Feedback sheets to Main Assessment objectives sheets
' Macro created 20/05/2010 by Susie ORiley
'
For Each sh In Array("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A010")
If SheetExists(sh & " Feedback") Then
With Sheets(sh & " Feedback").Range("C4", Sheets(sh & " Feedback").Range("C4").End(xlDown))
End With
If Worksheet.Name Like ("U?-" & sh) Then
Range("D3").Resize(, .Count) = Application.Transpose(.Value)
Else
End If
End Sub
The array worksheet names can stay as is, but I need the macro to be able to find the "U?-" & sh so I don't have to edit this macro each time I (or someone else) creates a new spreadsheet.
Any help would be most appreciated.
Thanks in advance.
I have already had some great help on this forum, but once again I am stuck and am hoping someone can help me.
I have a spreadsheet with multiple worksheet names, I want to copy some data across from e.g. the last 5 worksheet to the first 5 worksheets. The complication is that the worksheet names for the first 5 can change (U2-A01 up to U2-A010, or U3-A01 up to U3-A010 e.t.c.) and each spreadsheet can have up to 20 worksheets.
Rather than having to change the macro each time, I was hoping to use the LIKE operator to find the appropriate worksheet to copy to. I cannot get this working, but that's not surprising since my macro knowledge is very very poor.
The code is below:
Sub Copy_Objectives()
Dim sh As Variant
'
'
' Copies objectives from Feedback sheets to Main Assessment objectives sheets
' Macro created 20/05/2010 by Susie ORiley
'
For Each sh In Array("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A010")
If SheetExists(sh & " Feedback") Then
With Sheets(sh & " Feedback").Range("C4", Sheets(sh & " Feedback").Range("C4").End(xlDown))
End With
If Worksheet.Name Like ("U?-" & sh) Then
Range("D3").Resize(, .Count) = Application.Transpose(.Value)
Else
End If
End Sub
The array worksheet names can stay as is, but I need the macro to be able to find the "U?-" & sh so I don't have to edit this macro each time I (or someone else) creates a new spreadsheet.
Any help would be most appreciated.
Thanks in advance.