Hi, the code below looks at column A for the active sheet and then copy and pastes rows based on column A to other sheets.
sub distribute()
Dim i As Long
On Error Resume Next
For i = 2 To Range("A" & Rows.Count).End(3).Row
Rows(i).Copy
Sheets(Range("A" & i).Value).Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteAll
Next i
On Error GoTo 0
End Sub
problem: when I run it,I am getting a bunch of "#ref"'s because the code is not copy and pasting exactly what is on the master sheet.. I cannot post the excel sheet because it has sensitive information on it but here is an example.
On the master sheet, in cell AB8 is: "=1694200*ReferenceSheet!J4 ". When i run the code it will copy it to the correct sheet in cell AB5 but with "=1694200*ReferenceSheet!J1 " , therefor the result: #ref . My code is not changing anything on the 'reference sheet' and I can manually change "J1" to "j4" and it works fine, but there is too much data to change manually. How can I make the data copy and paste correctly?
On another issue I have the following:
With Sheets("ABM")
LR = .Range("AJ" & Rows.Count).End(xlUp).Row
.Range("AJ" & LR + 1).Value = FormatCurrency(WorksheetFunction.Sum(.Range("AJ3:AJ" & LR)))
.Range("AJ" & LR + 1).NumberFormat = "$#,##0_);[Red]($#,##0.)"
.Range("AJ" & LR + 1).Font.Size = 16
.Range("AJ" & LR + 1).Font.Bold = True
.Range("AJ" & LR + 1).Interior.ColorIndex = 15
End With
With Sheets("Adjudications")
LR = .Range("AJ" & Rows.Count).End(xlUp).Row
.Range("AJ" & LR + 1).Value = FormatCurrency(WorksheetFunction.Sum(.Range("AJ3:AJ" & LR)))
.Range("AJ" & LR + 1).NumberFormat = "$#,##0_);[Red]($#,##0.)"
.Range("AJ" & LR + 1).Font.Size = 16
.Range("AJ" & LR + 1).Font.Bold = True
.Range("AJ" & LR + 1).Interior.ColorIndex = 15
End With
BUT, there are 15 sheets, and I need to do it for around 20 columns. What I am doing now is copy and pasting exactly what I posted above and changing the sheet names to the 15 sheets and then changing the columns one at a time. The result is 300 "with sheets(sheet)...(code).....End With. The procedure is too long to run. Is there a way to condense this? There are 15 sheets and the columns that i need to refer to are Z-AN.
Thanks in advance!! :D
Bookmarks