I have 53 spreadsheets -- 1 for each week of the year.
DataEntry spdsht has columns: Date, Year, WeekNum, Contractor, Amount
I want to copy each row of data to the correct weekly spreadsheet. How can I select the correct spreadsheet (using the value in WeekNum column) and loop through the rows in DataEntry?
(Having 53 spreadsheets may not be the most efficient design but it is the most simple.)
Sub CopyData()
Sheets("DataEntry").Select
' Find the last row of data
FinalRow = Range("A5000").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column
ThisValue = Range("A" & x).Value
If ThisValue <> 0 Then
Range("A" & x & ":B" & x).Copy
Sheets("-----WeekNum------???").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("DataEntry").Select
ElseIf ThisValue = 0 Then
End If
Next x
End Sub
swtrader
-- If you don't know where you're going, you'll always know when you're not there.
DataEntry spdsht has columns: Date, Year, WeekNum, Contractor, Amount
I want to copy each row of data to the correct weekly spreadsheet. How can I select the correct spreadsheet (using the value in WeekNum column) and loop through the rows in DataEntry?
(Having 53 spreadsheets may not be the most efficient design but it is the most simple.)
Sub CopyData()
Sheets("DataEntry").Select
' Find the last row of data
FinalRow = Range("A5000").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column
ThisValue = Range("A" & x).Value
If ThisValue <> 0 Then
Range("A" & x & ":B" & x).Copy
Sheets("-----WeekNum------???").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("DataEntry").Select
ElseIf ThisValue = 0 Then
End If
Next x
End Sub
swtrader
-- If you don't know where you're going, you'll always know when you're not there.