问题描述:

I have been using a useful VB script that goes through a spreadsheet row by row, checks for duplicate cells in that row, deletes all the duplicates and shuffles all the cells along so there are no blanks.

It looks like this:

Sub StripRowDupes()

Do Until ActiveCell = ""

Range(ActiveCell, ActiveCell.End(xlToRight)).Select

For Each Cell In Selection

If WorksheetFunction.CountIf(Selection, Cell) > 1 Then

Cell.ClearContents

Else

End If

Next Cell

On Error Resume Next

Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft

ActiveCell.Range("A2").Select

Loop

End Sub

However, I now need to perform the same operation, only on a CSV file that has 48,051 columns and therefore wont load in excel due to its 16,000 column limit.

Can I run the script from the command line on the file?

How could I go about doing this?

网友答案:

You could load chunks of the .csv at a time, putting a prefix or suffix at the end of each import. Run VBA code on each chunk, then add back together.

Unfortunately the Workbooks.OpenText method supports importing text starting at a particular row, not a particular column, so you'd need to break up the .csv file into manageable chunks outside of excel, before running VBA code.

相关阅读:
Top