pour chacune des colonnes X de 1 à 140 : effacer les cellules (1,X) à (112,X) de la colonne X si rien en (2,X)
Dim couic As Range For Each c In Range(Cells(1, 1), Cells(112, 140)).Columns If Cells(2, c.Column) = "" Then If couic Is Nothing Then Set couic = Range(Cells(1, c.Column), Cells(112, c.Column)) Else Set couic = Application.Union(couic, Range(Cells(1, c.Column), Cells(112, c.Column))) End If End If Next couic.ClearContents Set couic = Nothing
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim couic As Object, c As Object For Each c In xlWKS.Range(xlWKS.Cells(1, 1), xlWKS.Cells(112, 140)).Columns If xlWKS.Cells(2, c.Column) = "" Then If couic Is Nothing Then Set couic = xlWKS.Range(xlWKS.Cells(1, c.Column), xlWKS.Cells(112, c.Column)) Else Set couic = Application.Union(couic, xlWKS.Range(xlWKS.Cells(1, c.Column), xlWKS.Cells(112, c.Column))) End If End If Next MsgBox couic.Address couic.ClearContents Set couic = Nothing
Public xlApp as object, xlBook as object, xlWKS As Object Public Fichier As String
Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open(Fichier) Set xlWKS = xlBook.WorkSheets(1)
With xlWKS For i= 3 To 19 Step 2 If (.Cells(2, i).Value) <> "" Then CmbPJs.AddItem (.Cells(2, i).Value) CmbXPMJ.AddItem (.Cells(2, i).Value) End If Next
j'ai déclaré Range as Object en Public dans ma Feuille principale