You are on page 1of 8

FMEV ASSIGNMENT

Capturing the Back End Operations of Practo Using


Macros in Excel
R Swetha | 15F156

Objective
The following assignment aims at capturing the back end activities of
transaction driven websites, where people can book appointments or
tickets. The example that has been considered in this assignment is the
worlds second largest healthtech start-up Practo.
Sheet 1- DATA
The data for the exercise was gathered from their website
https://www.practo.com/. While Practo has its services across various
cities and countries, for simplicity, only one Locality is considered in this
exercise, viz. Bangalore. Few physician primary type and the sub
specialisations that are listed on the website have been considered for this
exercise. For each of the specialisations, few doctors with respective
specialisations are considered (shown in Data sheet).
Sheet 2- FIND AND BOOK
The Sheet Find and Book acts as a User Interface. The users can find
and book appointments as per their desired data and time of
appointment. They can also select the physician or hospital they would
like to consult in the desired speciality using the dropdown menu. On
filling in the required details, the user can submit the form by clicking the
Submit button, for booking their appointment.
In the back-end, when any user submits the form their appointment
details get appended to a table, where all appointments are recorded,
which is accessible only by the database administrator of that website. For
these details to be transferred from the form to the table, a Macro named
table is used.
The VBA code for the aforementioned macros isSub table()
'
' table Macro
'

'
Application.ScreenUpdating = False
Sheets("Find and Book ").Select
Range("C7").Select
Selection.Copy
Sheets("Admin").Select
Range("B2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Admin").Select
ActiveCell.Offset(-2, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Admin").Select
ActiveCell.Offset(-2, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
ActiveCell.Offset(3, -1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Admin").Select
ActiveCell.Offset(-2, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 9
ActiveCell.Offset(4, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Admin").Select
ActiveCell.Offset(-2, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
ActiveCell.Offset(4, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Admin").Select
ActiveCell.Offset(-2, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Find and Book ").Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveCell.Offset(-4, 0).Range("A1").Select
Selection.ClearContents
ActiveCell.Offset(-4, 0).Range("A1").Select
Selection.ClearContents
ActiveCell.Offset(-3, 1).Range("A1").Select
Selection.ClearContents
ActiveCell.Offset(-2, 0).Range("A1").Select
Selection.ClearContents
ActiveCell.Offset(-2, 0).Range("A1").Select
Selection.ClearContents
ActiveCell.Offset(-6, -1).Range("A1").Select
ActiveWindow.ScrollRow = 1
End Sub

The VBA code is generated as a result of manually executing the macro


based on my requirement. The macros involved systematically copy
pastes the entries to the respective cells in the table and navigating to the
end of the rows using relative reference to append the table.
Sheet 3- ADMIN
All the new entries from the Find and Book Sheet gets appended to the
table Appointments Database which is monitored by the database
administrator. Now, from this master database, the administrator can
filter and display only todays appointments onto another excel sheet by
clicking Book todays appointments. On doing so, the calendars of the
respective doctors can be easily blocked for the appointments of that day.
This function of filtering and displaying only that days
appointment onto another worksheet is achieved by using the
following VBA code:
Sub booking()
Dim master As Long, book As Long
master = Sheets("Admin").Cells(Rows.Count, "B").End(xlUp).Row
book = Sheets("Appointments").Cells(Rows.Count, "B").End(xlUp).Row
For r = master To 2 Step -1
If Range("B" & r).Value = Date Then
Rows(r).Copy Destination:=Sheets("Appointments").Range("A" &
book + 1)
book = Sheets("Appointments").Cells(Rows.Count,
"B").End(xlUp).Row
End If
Next r
End Sub
The required code was generated using the code in the website
http://www.mrexcel.com/forum/excel-questions/715128-visual-basicapplications-copy-paste-entire-row-second-sheet-based-cell-value.html as
reference. A part of the code with following modifications were used:

Changing the names of the sheet as per requirement.


Only a part of the code was used. The else if part was not used
because date was the only criteria on which I wanted to copy to
another worksheet.
The lookup value for the If condition was changed to the respective
date on the system
The range was changed since the data in the relevant sheet starts
from column B, and not A.

Sheet 4- APPOINTMENTS
This sheet ideally displays all the appointments on the day the viewer is
viewing the table. A problem with the previous macro is that it does not
just update the table, rather again displays all the appointments as of that
day, without removing the duplicates. Hence, the macro update_table is
used. On clicking the button Update Appointments, all duplicates are
removed and all the bookings are sorted according to the time of their
appointments for that date. The VBA code of the aforementioned
macro is as follows:
Sub update_table()
'
' update_table Macro
'

'
Application.ScreenUpdating = False
Range("B4").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("B4:G50").Select
ActiveSheet.Range("$B$4:$G$50").RemoveDuplicates Columns:=3,
Header:=xlYes
ActiveWorkbook.Worksheets("Appointments").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Appointments").Sort.SortFields.Add
Key:=Range( _
"C5:C50"), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Appointments").Sort
.SetRange Range("B4:G50")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply

End With
Range("B4:B32").Select
Selection.AutoFilter
ActiveSheet.Range("$B$4:$B$32").AutoFilter Field:=1, Criteria1:= _
xlFilterToday, Operator:=xlFilterDynamic
Range("B4:G51").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0

.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("H12").Select
End Sub
Again, this VBA code was generated as a result of manually executing a
macro based on my requirements. The macro involves removing
duplicates based on name, sorting the list based on time and filtering the
list for todays date.
This final table Todays Appointments can help in blocking the respective
doctors calendars for the day.

References
[1]. https://www.practo.com/
[2]. http://www.mrexcel.com/forum/excel-questions/715128-visual-basicapplications-copy-paste-entire-row-second-sheet-based-cell-value.html
[3]. http://www.exceltrainingvideos.com/copy-data-to-another-excelworkbook-based-on-criteria-using-vba/

You might also like