Hi,
I have a list box with the 52 weeks of the year in listed as WK 1, WK 2 and so on up to WK 52.
So when a week is selected from the listbox all the data is copied from that week sheet on to my current weeks data sheet.
Here is part of my code. Its is all the same apart from the week numbers.
Is there any way of making this code better and quicker?
Any help would be appreciated.
Thanks
Dan
I have a list box with the 52 weeks of the year in listed as WK 1, WK 2 and so on up to WK 52.
So when a week is selected from the listbox all the data is copied from that week sheet on to my current weeks data sheet.
Here is part of my code. Its is all the same apart from the week numbers.
Is there any way of making this code better and quicker?
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
If ListBox1.Value = "WK 1" Then
Sheets("Current weeks data").Cells.ClearContents
Sheets("WK 1").Select
ActiveSheet.Rows("1:" & ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row).Copy
Sheets("Current weeks data").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").Select
ElseIf ListBox1.Value = "WK 2" Then
Sheets("Current weeks data").Cells.ClearContents
Sheets("WK 2").Select
ActiveSheet.Rows("1:" & ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row).Copy
Sheets("Current weeks data").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").Select
ElseIf ListBox1.Value = "WK 3" Then
Sheets("Current weeks data").Cells.ClearContents
Sheets("WK 3").Select
ActiveSheet.Rows("1:" & ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row).Copy
Sheets("Current weeks data").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").Select
ElseIf ListBox1.Value = "WK 4" Then
Any help would be appreciated.
Thanks
Dan