Data Processing & Cleanup Beginner

Data Processing & Cleanup

Remove duplicates, clean data formats, and standardise entries

71 views
Featured

Perfect For:

  • Remove duplicate entries
  • Standardise text formatting
  • Clean imported data
VBA Code
Sub CleanDataRange()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long

    Set ws = ActiveSheet
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

    ' Remove duplicates
    ws.Range("A1:C" & lastRow).RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes

    ' Clean up text formatting
    For i = 2 To lastRow
        ws.Cells(i, 1).Value = Trim(UCase(ws.Cells(i, 1).Value))
        ws.Cells(i, 2).Value = Trim(ws.Cells(i, 2).Value)
    Next i

    MsgBox "Data cleanup complete!"
End Sub

Related Topics

data cleanup duplicates formatting

Need Custom VBA Solutions?

Our AI-powered VBA generator can create custom code tailored to your specific requirements in seconds.

Generate Custom VBA Code