Delete duplicate rows in excel vba6/20/2023 ![]() It's not clear whether that r stands for Range (in which case it's useless Hungarian Notation), and Before what this range is. And now you have a free, global-scope worksheet object referring to that specific sheet, readily usable everywhere in that VBA project - which makes this wsSource variable redundant as well. Locate that "source" worksheet in the Project Explorer, then look at its (Name) property - change it from what defaults to e.g. ![]() This includes any worksheet that exist at compile-time in ThisWorkbook: Dim wsSource As WorksheetĮvery worksheet has a CodeName property, that you can change in the properties toolwindow (F4). Don't do that, use the globals that are right there waiting to be referenced instead. Now, there's no need for this variable Application is free, globally-scoped, and you're not owning that instance - just copying a reference to an existing object. Code is easier to follow when you don't need to constantly scroll up and down and back to know what's what: by declaring variables closer to their usage, you reduce the cognitive load and avoid that scrolling. The rather procedure begins with a good dozen variable declarations. Stylistically though, the code could use some help anyway. Seems Range.RemoveDuplicates could turn it all into a much more efficient one-liner. XlApp.StatusBar = Format(i & " out of " & size) & " Rows Complete" ![]() Set rBefore = wsSource.Range(wsSource.Cells(2, 1), wsSource.Cells(, 1)) I think I'll most likely need this once, so please bear with me since it probably looks terrible.Ĭode I would like reviewed: Option Explicit I'm curious if there's any way I can substantially improve its speed (it runs through >200k rows). ![]()
0 Comments
Leave a Reply. |