Hello everyone, can anyone help me please, I want to use this excel macro and convert to basic, my first button in sheet named “Ajouter” when I click on it, it will create cells in another sheet called “Historiques” and this button will be deleted from that sheet and will create another button called CommandButton1 which eventually start another macro…any help is appreciated ,thanks
Sub EnregistrerButtonInitial_Click()
Dim sName As String
Dim WorkRngDay As Range
Dim btn As Button
Dim t As Range
Dim Obj As Object
Dim Code As String
i = 1
Set WorkRngDay = Range("G1,C37:F40,C49:F52,C63:I63,C69:I69,C75:G75,C81:G81,C6:H6")
Set ResponsableDay = Range("G1")
sName = Format(Date, "mm-dd-yyyy")
If WorksheetExists(sName) Then
MsgBox "Feuilles déjà Existante !"
ElseIf CellsVides(WorkRngDay) = True Then
Sheets("Ajouter").Copy after:=ActiveSheet
ActiveSheet.Tab.ColorIndex = xlColorIndexNone
ActiveSheet.Shapes.SelectAll
Selection.Delete
ActiveSheet.Name = sName
lastrow = Sheets("Historiques").Range("C" & Rows.Count).End(xlUp).Row + 1
ActiveSheet.Hyperlinks.Add ActiveSheet.Range("K1"), "", "'Historiques'!C" & lastrow, "", "Retour à l'historique"
Set t = ActiveSheet.Range("M1")
Set Obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=t.Left, Top:=t.Top, Width:=t.Width, Height:=t.Height)
ActiveSheet.OLEObjects(1).Object.Caption = "Enreg. Final"
ActiveSheet.OLEObjects(1).Object.BackColor = vbActiveTitleBar
Sheets("Historiques").Range("A" & lastrow) = Format(Date, "mm-dd-yyyy")
Sheets("Historiques").Range("B" & lastrow) = ResponsableDay
Sheets("Historiques").Hyperlinks.Add Sheets("Historiques").Range("C" & lastrow), "", "'" & sName & "'!A1", "", "feuille: " & sName
ClearUnprotectedCells
SaveMyChanges
MsgBox "Jour Enregistrement avec succes!"
Else
MsgBox "Veuiller saisir les champs obligatoires!"
End If
End Sub