R
ryguy7272
Complex Copy
I need to do somewhat of a complex comparison between values in two columns.
Basically, the macro below will create a new sheet and copy/paste two sets
of data from two sheets into the new sheet that was just created.
Sub ComplexCopy()
'Delete the sheet "Summary-Sheet" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("Analysis-Sheet").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'Add a worksheet with the name "Summary-Sheet"
Set Basebook = ThisWorkbook
Set Newsh = Basebook.Worksheets.Add
Newsh.Name = "Analysis-Sheet"
'Sheets(1).Move After:=Sheets(Sheets.Count)
Sheets("Analysis-Sheet").Move After:=Sheets(Sheets.Count)
Sheets("Analysis of Interest Prior").Select
Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 0).Resize(, 5).Copy
'ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Analysis-Sheet").Select
Range("A11").Select
ActiveSheet.Paste
Sheets("Analysis of Interest Current").Select
Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 0).Resize(, 5).Copy
'ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Analysis-Sheet").Select
Range("F11").Select
ActiveSheet.Paste
End Sub
That part works fine. The part that is tripping me up is the part when I
have to compare values in Column A (AccountNumber) and values in Column F
(AccountNumber; often the same, but sometimes different). If the two Account
Numbers are the same, I want copy the value in Column J of the same row into
Column F. If the two values are different, copy from Column F to Column J,
of the same row, to the bottom of the list, and I’ll eventually create a
little snippet of code to do a sort right at the end of the Sub. I tried to
get my results with a Pivot Table; didn’t really seem to work due to an
inability to compare the Account Numbers. Any ideas on how to do this?
Thanks,
Ryan---
I need to do somewhat of a complex comparison between values in two columns.
Basically, the macro below will create a new sheet and copy/paste two sets
of data from two sheets into the new sheet that was just created.
Sub ComplexCopy()
'Delete the sheet "Summary-Sheet" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("Analysis-Sheet").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'Add a worksheet with the name "Summary-Sheet"
Set Basebook = ThisWorkbook
Set Newsh = Basebook.Worksheets.Add
Newsh.Name = "Analysis-Sheet"
'Sheets(1).Move After:=Sheets(Sheets.Count)
Sheets("Analysis-Sheet").Move After:=Sheets(Sheets.Count)
Sheets("Analysis of Interest Prior").Select
Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 0).Resize(, 5).Copy
'ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Analysis-Sheet").Select
Range("A11").Select
ActiveSheet.Paste
Sheets("Analysis of Interest Current").Select
Range("A11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 0).Resize(, 5).Copy
'ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Analysis-Sheet").Select
Range("F11").Select
ActiveSheet.Paste
End Sub
That part works fine. The part that is tripping me up is the part when I
have to compare values in Column A (AccountNumber) and values in Column F
(AccountNumber; often the same, but sometimes different). If the two Account
Numbers are the same, I want copy the value in Column J of the same row into
Column F. If the two values are different, copy from Column F to Column J,
of the same row, to the bottom of the list, and I’ll eventually create a
little snippet of code to do a sort right at the end of the Sub. I tried to
get my results with a Pivot Table; didn’t really seem to work due to an
inability to compare the Account Numbers. Any ideas on how to do this?
Thanks,
Ryan---