Data Processing & Cleanup

Remove duplicates, clean data formats, and standardise entries

4778 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.

Free AI generations every month — top up with credit packs anytime

Related Templates

More VBA templates in the same category

Intermediate

Timesheet & Attendance Tracker

Track employee working hours, overtime, absences, and holidays with automatic calculations, weekl...

View Template
Intermediate

Data Entry Form with Validation

Professional UserForm-based data entry system with field validation, dropdown lists, date pickers...

View Template
Intermediate

Create Sheet Per Unique Value

Automatically create separate worksheets for each unique value in a column. Perfect for splitting...

View Template