Professional Documents
Culture Documents
Transfer Data From Microsoft Excel To Google Sheet - TheDataLabs
Transfer Data From Microsoft Excel To Google Sheet - TheDataLabs
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 1/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Most of the time, we use Microsoft Excel to process and store the data. We always face challenges if multiple users are
sitting at different locations and using MS Excel or VBA UserForm to transfer and save the records in a particular database.
In multi-user environment, we need a shared drive where we can keep our database or Excel file to get the user’s input in a
centralized way. Getting a designated shared drive is costly and not possible in small companies or for individuals. To
handle this scenario, we need a free and secure solutions.
Google Drive, Google Sheet and Google Form provide a dynamic solution to store data in a centralized way without
worrying about user platform and location. It’s free of cost and fully secure hence, we don’t need to think about data
protections and server maintenance.
All the features of Google Drive and Google Sheet raise a question in our mind, Can we use Google Drive or Google Sheet
as a database? And the answer is Yes, we can.
In this post, we will learn how to Use Google Drive and Google Sheet to transfer data from MS Excel.
So without any delay, let us start developing this interesting application from scratch.
Develop Excel Based Form to Transfer Data from Excel to Google Sheet
Open a new Excel Workbook and save the file with the name “MS Excel To Google Sheet”. Make sure the extension of this
file is .XLSM.
Create a Home page (worksheet) and design a button so that user can click on that button to launch form and submit data.
Design the landing sheet as available in below image.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 2/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
To open VBA window, just click on Developer Tab, select Visual Basic icon available in Code group.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 3/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
To insert a blank form, click on Insert menu then select UserForm from menu items.
To write sub procedure to Reset the UserForm and Transfer data to Google sheet, we need to add a Module in our project.
To insert a module, click on Insert menu then select Module from the available menu items.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 4/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Inserting a Module
This particular reference will help us in performing web queries to get and submit data. We will understand the coding
thoroughly in later part of our tutorial.
To add the Microsoft XML, v6.0 reference, click on Tools menu then click on References. Find & select it from available
references list in Reference window and then click on OK button.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 5/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Please refer the below image to design the UserForm and set the properties. We will refer the same name and controls in
our coding.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 6/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Once you will complete the UserForm designing and properties, it will look like below form in running mode.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 7/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
1 Sub Reset()
2
3 With frmForm
4
5 .txtEmpID.Value = ""
6 .txtEmpName.Value = ""
7 .optFemale.Value = False
8 .optMale.Value = False
9 .cmbDesignation.Clear
10
11 .cmbDesignation.AddItem "Executive"
12 .cmbDesignation.AddItem "Sr. Executive"
13 .cmbDesignation.AddItem "Team Leader"
14 .cmbDesignation.AddItem "Manager"
15 .cmbDesignation.AddItem "Sr. Manager"
16 .cmbDesignation.AddItem "Associate Director"
17 .cmbDesignation.AddItem "Director"
18
19 .txtAddress.Value = ""
20
21 End With
22 End Sub
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 8/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
In this procedure, we are clearing values and selection from input controls. We are also adding the required elements in
ComboBox (cmbDesignation).
Now, the only one Sub Procedure is pending and that is for Transferring data from Excel to Google Sheet. We will complete
this coding after creating a Google Sheet and Form in Google Drive. So, let’s move to the next phase of our development.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 9/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Click on Google App icon available on the top-right side in window and select the Google Drive.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 10/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 11/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
To do that just right click in Folder and select ‘Google Sheet Database’. It will open a blank Google sheet in new tab. Just
visit to Google Sheet Tab and change the ‘Untitled Spreadsheet’ to ‘Google Sheet Database’. Also, rename the ‘Sheet1’ to
‘Data’. Now close this tab. Once you close the Google Sheet, you can see a Google Sheet available in folder.
Creating a Google Sheet and Changing the title and sheet name
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 12/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Change the Form title from ‘Untitled Form’ to ‘Employee Data Entry Form’. Also, add the description as ‘Form to capture
employee details’.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 13/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Now, we have done with Form title and description. Let us add the questions and required fields in our form. To add
questions, just click on + icon available in floating menu. Also, choose the field type from the drop-down available to the
right side of question title.
Here, we need to add fields for Employee ID, Employee Name, Gender, Designation and Address. See the below image and
follow the steps.
Now, we have done with adding questions and respective fields in Google Form. Let us select the response destination to
store input data in Google Sheet.
By default, Google Forms create a Google Sheet to store its data but here, we are taking control in our hand and going to
utilize the Google Sheet, which we created i.e. Google Sheet Database.
To select the response destination, click on ‘Responses’ available beside the ‘Questions’ button available on top of Google
Form. It will open the ‘Responses’ window. Now, click on ‘More’ icon (three dots) then click on ‘Select response destination’
in pop-up menu. In select response destination window, just click on ‘Select existing spreadsheet’ and the click on ‘Select’,
choose the ‘Google Sheet Database’ from the available Google sheets and then click on ‘Select’.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 14/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Now, Google Form linked with the Google sheet. Here, Google sheet will store all the responses submitted by either Google
Form or Microsoft Excel. It will work like a centralized database to store entire data transferred by users.
So, we have completed the Google Form and Google Sheet. Now, it’s time to get pre-filled link of Google Form so that it can
be used in our VBA coding to transfer data from MS Excel to Google Sheet.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 15/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
This URL the pre-filled URL which we can use to fill and then submit the data. This URL has two different parts. Let’s break
it and understand
https://docs.google.com/forms/d/e/1FAIpQLSegAIkkFc1EoIaF5WQIxchEyrVLW3zsjbkP5WDHQB2sIIQK3Q/viewform?
This is the first part of the URL, which is to view the google form. Here, we need to make some changes in the first part so
that we can utilize in our coding to transfer the data. In this URL, just change viewform? with formResponse?ifq
Here, formRespose has been used to get the response from Google Form after submitting the details through VBA code.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 16/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
“&entry.837233042=1254&entry.413407046=Dilip+Kumar&entry.1383004734=Male&entry.356904377=Manager&entry.47
9173200=New+City”
Second part of URL contains “name” attributes for the text boxes, option button and combobox used in Google Form. Here,
entry.837233042 and entry.413407046 are the name value for two text boxes, Employee ID and Employee Name.
Similarly, entry.1383004734 is for Gender, entry.356904377 for designation and entry.479173200 is for Address.
For coding we need to replace the field values (bold text in below link) with respective variables name and then at the end
of the link just add &submit=Submit to post all the data to Google Form.
“&entry.837233042=1254&entry.413407046=Dilip+Kumar&entry.1383004734=Male&entry.356904377=Manager&entry
.479173200=New+City” & “&submit=Submit”
Now, we understood the technicalities and changes required in URL. Let us write the pending Sub Procedure to transfer the
data from MS Excel to Google Sheet.
1 Sub SendToGoogle()
2
3 'This Macro Requires Reference to "Microsoft XML, v6.0" (VBA Editor > Tools > References, find & select from list)
4
5 Dim URL_First As String 'Assign the first part of URL to send the data
6 Dim URL_Last As String 'Assign the last part of URL where we will update the information
7 Dim Form_URL As String 'To store the Form URL after merging Beginning and End URL
8
9 Dim HeaderName As String 'Variable to store the header type i.e. Content-Type
10 Dim SendID As String 'To store the information required to send a particular information to Google form
11
12 'Variables to store user inputs from Excel UserForm
13 Dim EmpID As String
14 Dim EmpName As String
15 Dim Gender As String
16 Dim Designation As String
17 Dim Address As String
18
19
20 'Assign User inputs to variables
21
22 EmpID = frmForm.txtEmpID.Value
23 EmpName = frmForm.txtEmpName.Value
24 Gender = IIf(frmForm.optFemale.Value, "Female", "Male")
25 Designation = frmForm.cmbDesignation.Value
26 Address = frmForm.txtAddress.Value
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 17/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
27
28 'Variable to store what we need to send to server
29
30 Dim TicketInfo As MSXML2.ServerXMLHTTP60 'XML variable to send the information to server
31
32 'Content-Type is actually a header type which tells the client what the content type of the returned content actually is. Goog
33
34 HeaderName = "Content-Type"
35
36 'SendID required to send a particular information to Google Form
37 SendID = "application/x-www-form-urlencoded; charset=utf-8"
38
39 'In actual link, we need to replace viewform? with formResponse?ifq&
40 'need to find the “name” attributes for the text boxes and the value for them
41 'add at the end &submit=Submit and use it, it must post all the data you specified in one step.
42
43 'formRespose is used to get the response from Google Form after submitting the details
44 'Submit - it is a command to submit the filled form
45
46 URL_First = "https://docs.google.com/forms/d/e/1FAIpQLSegAIkkFc1EoIaF5WQIxchEyrVLW3zsjbkP5WDHQB2sIIQK3Q/formResponse?ifq"
47
48 URL_Last = "&entry.837233042=" & EmpID & "&entry.413407046=" & EmpName & "&entry.1383004734=" &
49
50 'Creating the Final URL
51 Form_URL = URL_First & URL_Last
52
53 Set TicketInfo = New ServerXMLHTTP60 'Setting the reference of new server xmlhttp 60
54
55 TicketInfo.Open "POST", Form_URL, False ' Posting the entire link
56
57 TicketInfo.setRequestHeader HeaderName, SendID 'Specifies the name of an HTTP header.
58
59 TicketInfo.send 'Send all the information over google
60
61 'StatusText is provide the status of data submission. It will show OK if data will be successfully submitted
62
63 If TicketInfo.statusText = "OK" Then 'Check for successful send
64
65 Call Reset 'Call Reset procedure to reset form Excel Form after submitting the data
66 MsgBox "Thank you for submitting data!"
67
68 Else
69 MsgBox "Please check your internet connection & required details"
70 End If
71
72 End Sub
Let’s call this Sub Procedure on click event of cmdAdd command Button. To write the code, just move to UserForm code
window and write the below code.
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 18/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
10
11 End Sub
Let’s move to code window of module and write a sub procedure to show the user form.
1 Sub ShowForm()
2 frmForm.Show
3 End Sub
To assign the macro, just right click on ‘Launch Form’ button, select ‘Assign Macro’ and from Assign Macro window, just
select the ‘Show Form’ from the available macros in ThisWorkbook macro list and then click on OK.
Assign macro
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 19/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Here, this application is working perfectly. We can transfer the data from Microsoft Excel to Google Sheet without facing any
issues. This tool will work in multi-user environment.
Part 1 – Creating UserForm in Excel and Write code to reset the form
Part 2 – Creating Google Sheets, Google Form, linking Google Form with Google Sheets and generating pre-filled link of
Google Form
Part 3 – Understanding Pre-Filled Link of Google Form and Writing Code to Transfer Data from Excel to Google Sheets
Please click on below button to download the Excel file used in this tutorial. Password to open the VBA code is
thedatalabs.
Click to download
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 20/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
Keywords
How to use Google Drive and Google sheet as a database for Excel Application?
TheDataLabs
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 21/22
04/01/2021 Transfer Data from Microsoft Excel to Google Sheet | TheDataLabs
https://thedatalabs.org/transfer-data-from-microsoft-excel-to-google-sheet/ 22/22