Created
June 2, 2020 14:30
-
-
Save mansouryaacoubi/4103a6c4cbc1da857ce1edba2bc05d8d to your computer and use it in GitHub Desktop.
Save and Print Excel Data for BCP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Author: Mansour Yaacoubi | |
' Timestamp: 2020-06-02 13:00 UTC+0 | |
' Summary: This script deals with the | |
' document of the BCP and automates | |
' tasks for the employees | |
' Responsible: Mohammed Ngadi | |
Sub Button1_Click() | |
' TODO: Check previously if empty before printing | |
PrintDocument | |
SaveToRepository | |
ClearData | |
End Sub | |
Private Sub PrintDocument() | |
Sheets("Vue d'Impression").Activate | |
Application.Wait Now + TimeSerial(0, 0, 1) | |
Sheets("Vue d'Impression").PrintOut | |
End Sub | |
Private Sub SaveToRepository() | |
' Retrieve new repository id | |
Dim newId As Integer | |
newId = Sheets("Formulaire").Range("D7").Value | |
' Retrieve new row id | |
Dim newRow As Long | |
newRow = Sheets("Répertoire").Cells(Rows.Count, 3).End(xlUp).Row + 1 | |
' Add new data to repository | |
Sheets("Répertoire").Range("C" & newRow).Value = newId | |
Sheets("Répertoire").Range("D" & newRow).Value = Sheets("Formulaire").Range("D9") | |
Sheets("Répertoire").Range("E" & newRow).Value = Sheets("Formulaire").Range("D11") | |
Sheets("Répertoire").Range("F" & newRow).Value = Sheets("Formulaire").Range("D13") | |
End Sub | |
Private Sub ClearData() | |
' Go to form sheet | |
Sheets("Formulaire").Activate | |
' Clear client data | |
Range("D9").Value = "" | |
Range("D11").Value = "" | |
Range("D13").Value = "" | |
Range("D15").Value = "" | |
Range("D17").Value = "" | |
' Clear benificient data | |
Range("D21").Value = "" | |
Range("D23").Value = "" | |
Range("D25").Value = "" | |
' Show MessageBox | |
MsgBox "Data has been saved with ID #" & Range("D7").Value - 1 | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment