Denne funktion kan fjerne 0 i et vilkårligt ark og vilkårlig kolonne:
Public Function Del0s(ByVal objSheet As Excel.Worksheet, ByVal strRange As String)
Dim oCell As Excel.Range
Dim oSheet As Excel.Worksheet
Set oSheet = objSheet
Dim RowsDel As Integer
RowsDel = 0
For Each oCell In oSheet.Range(strRange)
If oCell.Value = 0 Then
oCell.Value = Empty
RowsDel = RowsDel + 1
End If
Next
Set oSheet = Nothing
Set oCell = Nothing
Del0s = RowsDel
End Function
Du bruger funktionen således:
Public Sub Delete()
Dim oSheet As Excel.Worksheet
Dim RowsAffected As Integer ' Kan bruges til at gøre status
Application.EnableEvents = False
For Each oSheet In Application.Worksheets
If oSheet.Name = "blablah" Then ' Det sheet du vil tjekke (brug SELECT CASE hvis det er mange)
RowsAffected = Del0s(oSheet, "U:U")
' Her kan du skrive RowsAffected et eller andet sted
End If
Next
End Sub
Så kan du jo vælge om du vil have en knap eller trykker alt+F8 eller køre det i forbindelse med din Upload kode..
Værs'go!
Venlig hilsen Jon