data_fiddler
New Member
- Joined
- Feb 5, 2011
- Messages
- 3
I'm new to MrExcel.com and Macros/VBA in general. I've been watching tutorial videos on Macros like crazy in order to help me put together a Macro for something I'm working on.
My workbook contains a large amount of data (i.e. one of the worksheets contains 169 columns with 112,000 rows of data). Within all of this data, there is a unique value in column DH (account number in numerical format). Each account number should only exist one time within this sheet. However, there are some duplicate rows of data. My goal is to remove all of the duplicate rows and place them in a separate sheet titled 'Duplicates'.
The way I've been doing this so far has been taking me an extraordinary amount of time and I know there must be a quicker way of getting this done. What I did first was I sorted column DH in numerical order, from least to greatest. Next, I used Conditional Formatting to format the font of all duplicate values in column DH as a bold red color. After that was completed, I would Page Dn starting from row one looking for bold red values within column DH. Once I found some values that were formatted in that manner, I would highlight the duplicate rows of data (usually one row but sometimes two or three) and 'Cut' the row, then I would go to the 'Duplicates' sheet and paste the row there. Then I would go back to my previous sheet, delete the empty row I just cut, and repeat the process.
I tried to record a macro for this process and here's what it looks like:
Sub Remove_Duplicate_Service_Accounts()
'
' Remove_Duplicate_Service_Accounts Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
Rows("14253:14253").Select
Range("Z14253").Activate
Selection.Cut
Sheets("Duplicates").Select
Range("A2").Select
ActiveSheet.Paste
Range("A3").Select
Sheets("Survey (Nov. 09-Dec. 10)").Select
ActiveWindow.LargeScroll Down:=1
Range("Z14284").Select
ActiveWindow.LargeScroll Down:=1
Rows("14328:14328").Select
Range("Z14328").Activate
Selection.Cut
Sheets("Duplicates").Select
ActiveSheet.Paste
Range("A4").Select
Sheets("Survey (Nov. 09-Dec. 10)").Select
End Sub
I know it's not right so I could really use some help! Any feedback would be greatly appreciated! I've also included a screenshot of my workbook for you to get a better idea of what I'm talking about.
My workbook contains a large amount of data (i.e. one of the worksheets contains 169 columns with 112,000 rows of data). Within all of this data, there is a unique value in column DH (account number in numerical format). Each account number should only exist one time within this sheet. However, there are some duplicate rows of data. My goal is to remove all of the duplicate rows and place them in a separate sheet titled 'Duplicates'.
The way I've been doing this so far has been taking me an extraordinary amount of time and I know there must be a quicker way of getting this done. What I did first was I sorted column DH in numerical order, from least to greatest. Next, I used Conditional Formatting to format the font of all duplicate values in column DH as a bold red color. After that was completed, I would Page Dn starting from row one looking for bold red values within column DH. Once I found some values that were formatted in that manner, I would highlight the duplicate rows of data (usually one row but sometimes two or three) and 'Cut' the row, then I would go to the 'Duplicates' sheet and paste the row there. Then I would go back to my previous sheet, delete the empty row I just cut, and repeat the process.
I tried to record a macro for this process and here's what it looks like:
Sub Remove_Duplicate_Service_Accounts()
'
' Remove_Duplicate_Service_Accounts Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
Rows("14253:14253").Select
Range("Z14253").Activate
Selection.Cut
Sheets("Duplicates").Select
Range("A2").Select
ActiveSheet.Paste
Range("A3").Select
Sheets("Survey (Nov. 09-Dec. 10)").Select
ActiveWindow.LargeScroll Down:=1
Range("Z14284").Select
ActiveWindow.LargeScroll Down:=1
Rows("14328:14328").Select
Range("Z14328").Activate
Selection.Cut
Sheets("Duplicates").Select
ActiveSheet.Paste
Range("A4").Select
Sheets("Survey (Nov. 09-Dec. 10)").Select
End Sub
I know it's not right so I could really use some help! Any feedback would be greatly appreciated! I've also included a screenshot of my workbook for you to get a better idea of what I'm talking about.
