1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| Public Function GetDataFromRg(rgData As Range, vtab_Out As Variant, stErrMsg As String) As Boolean
'fonction qui permet d'aspirer des données dès lorsqu'on connait au moins une cellule dans la feuille.
On Error GoTo ErrorHdlr
vtab_Out = rgData.CurrentRegion.Cells.Value
GetDataFromRg = True
Exit Function
ErrorHdlr:
stErrMsg = "Erreur dans le Range"
End Function
Public Function PasteDataInRg(vtabToPaste As Variant, rgToPaste As Range, stErrMsg As String) As Boolean
Dim iRow As Long
Dim iCol As Long
Dim iMaxRow As Long
Dim iMaxCol As Long
Dim iMinRow As Long
Dim iMinCol As Long
With rgToPaste
iRow = .Row
iCol = .Column
End With
iMaxCol = UBound(vtabToPaste, 2)
iMaxRow = UBound(vtabToPaste, 1)
iMinCol = LBound(vtabToPaste, 2)
iMinRow = LBound(vtabToPaste, 1)
rgToPaste.Range(TranscoNb2Car(iCol) & iRow & ":" & TranscoNb2Car(iCol + iMaxCol - iMinCol) & iRow + iMaxRow - iMinRow).Value = vtabToPaste
PasteDataInRg = True
End Function
'///////////////////////////////
'
' MAIN
'
'
Public Sub Main()
Dim vtabData As Variant
Dim iDataMaxRow As Long
Dim stErrMsg As String
Dim vtabResult As Variant
'Get data
If Not GetDataFromRg(ThisWorkbook.Sheets(NOM_FEUILLE).Range(NOM_RANGE), vtabData, stErrMsg) Then GoTo ErrorHdlr
'la je ne peux pas du tout t'aider car seul toi sait ce qu'il y a dans ton tableau et ce qu'il faut dans ton report
If Not MakeMyReport(vtabData, vtabResult, stErrMsg) Then GoTo ErrorHdlr
'Paste
If Not PasteDataInRg(vtabResult, ThisWorkbook.Sheets(NOM_FEUILLE).Range(NOM_RANGE), stErrMsg) Then GoTo ErrorHdlr
Exit Sub
ErrorHdlr:
MsgBox stErrMsg, vbOKOnly, "Attention Erreur!"
End Sub |
Partager