Hi,
I want to merge data from different sheets.
I've come across several problem and i have done some "work" on it, but i'm unable to go further in the resolution of my problem.
Here is the code that i've made and that is working for now ![Smilie](https://www.excelforum.com/images/smilies/smile.gif)
Sub CLEANUP()
For i = 3 To Sheets.Count
Worksheets(Worksheets(i).Name).Select
Cleanuptmp = iFindRowDat(Worksheets(Sheets(1).Name).Cells(1, 1).Value, Worksheets(i).Name)
'Supprime les lignes jusqu'a ce que la premiere lignes soit celle contenant le header du tableau utile
While Cleanuptmp <> 1
Cells(Cleanuptmp - 1, 1).EntireRow.Delete
Cleanuptmp = iFindRowDat(Worksheets(Sheets(1).Name).Cells(1, 1).Value, Worksheets(i).Name)
Wend
'Supprime les premieres colonnes si elles sont vident
While Cells(1, 1).Value = ""
Cells(1, 1).EntireColumn.Delete
Wend
'Supprime la ligne blanche entre le header et les données du tableau
While Cells(2, 2).Value = ""
Cells(2, 2).EntireRow.Delete
Wend
Next i
End Sub
'Trouver la derniere ligne utilisée dans un page
Function LastRow(WorksheetName As String) As Long
With Worksheets(WorksheetName)
On Error Resume Next
LastRow = .Cells.Find("*", .Cells(1), xlFormulas, xlWhole, xlByRows, xlPrevious).Row
If Err <> 0 Then xlLastRow = 0
End With
End Function
'Trouver la colonne contenant data, renvoit le numéro de colonne
Function iFindColDatN(Data As String, WorksheetName As String) As Integer
Worksheets(WorksheetName).Select
t = 1
While Cells(1, t) <> Data
t = t + 1
Wend
End Function
'Trouver la colonne contenant data, renvoit la lettre de la colonne
Function iFindColDatL(Data As String, WorksheetName As String) As String
iFindColDatL = ColLet(iFindColDatN(Data, WorksheetName))
End Function
'Converti numéro de colonne en nom de colonne
Function ColLet(ColNum As Integer) As String
If ColNum > 26 Then
'Colonne multi lettre
ColLetr = Chr(Int((ColNum - 1) / 26) + 64) & Chr(((ColNum - 1) Mod 26) + 65)
Else
'Colonne mono lettre
ColLet = Chr(ColNum + 64)
End If
End Function
'Trouve le numéro de ligne contenant l'information DATA (pour incrémentation et recoupement ultérieur)
Function iFindRowDat(Data As String, WorksheetName As String) As Integer
Worksheets(WorksheetName).Select
On Error Resume Next
iFindRowDat = Cells.Find(Data).Row
If Err <> 0 Then iFindRowDat = 0
While 1 <> 0
End Function
I've joined the output that i want, the code that i've mentionned above would be ran from the first page, that will contains some options if needed, and some information regarding the macro usage.
If anyone could help, this would be great.
thx in advance,
Regards,
MrCarembole.
Bookmarks