How to Create a Database That Updates Automatically in Excel

  Рет қаралды 31,340

ExcelDemy

ExcelDemy

Күн бұрын

Пікірлер: 10
@blakearndt3771
@blakearndt3771 Жыл бұрын
I can see this video was planned out very well and presented very well by someone who is knowledgeable and genuine. Thanks for sharing 👍👍
@exceldemy2006
@exceldemy2006 Жыл бұрын
Thank you! Stay connected with Exceldemy for more helpful content! 🎉❤ Regards, Exceldemy Team!
@amruthacv2432
@amruthacv2432 7 ай бұрын
Method 3 is directly connected to the database right? . I am working on a project where the sql data is formatted to excel and if any changes are made in that then it should also reflect in the database
@exceldemy2006
@exceldemy2006 7 ай бұрын
Dear, method 3 describes how to automatically update a pivot table, which represents data in Excel, using VBA code. It does not directly connect to an external database like SQL. To achieve this, VBA must establish a connection to the SQL database and execute SQL commands to update the database when changes are made in Excel.
@amruthacv2432
@amruthacv2432 7 ай бұрын
@@exceldemy2006 oh okay do u have a video tutorial for that? Thanks for answering my question
@exceldemy2006
@exceldemy2006 7 ай бұрын
@@amruthacv2432 Dear, you are welcome. We will definitely try to create a tutorial on connecting to a database and updating data using Excel VBA. We are delighted to inform you that we have demonstrated a situation in which you make changes in Excel and the changes are reflected in the Database. Please check the following SOLUTION Overview: www.exceldemy.com/wp-content/uploads/2024/04/Connecting-to-MS-SQL-Server-And-Update-DATABASE-Using-Excel-VBA.gif You can download the solution workbook: www.exceldemy.com/wp-content/uploads/2024/04/Amrutha-C-V-SOLVED.xlsm Necessary Excel VBA Code in Sheet Module: Public oldValue As Variant Private Sub Worksheet_SelectionChange(ByVal Target As Range) oldValue = Target.Value End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Dim cell As Range Dim newValue As Variant Dim rowFinderME As String Dim rowFinderWS As String Set rng = Me.Range("A:D") If Not Intersect(Target, rng) Is Nothing Then Application.EnableEvents = False If Target.Column = 1 Then MsgBox "The ID column is considered as the primary key.", vbCritical Me.Cells(Target.Row, Target.Column).Value = oldValue Dim conn As ADODB.Connection Set conn = New ADODB.Connection Dim cmd As New ADODB.Command Dim serverName As String Dim databaseName As String Dim SQL As String serverName = "DESKTOP-94N3HCQ\SQLEXPRESS01" databaseName = "ProductInformation" conn.ConnectionString = "driver={SQL Server};server=" & serverName & ";database=" & databaseName conn.ConnectionTimeout = 100 conn.Open conn.Close ElseIf Target.Column = 2 Then ConnMsSQLDatabaseAndUpdate "Name", Target.Value, Target.Offset(0, -1).Value ElseIf Target.Column = 3 Then ConnMsSQLDatabaseAndUpdate "Price", Target.Value, Target.Offset(0, -2).Value ElseIf Target.Column = 4 Then ConnMsSQLDatabaseAndUpdate "Quantity", Target.Value, Target.Offset(0, -3).Value End If Application.EnableEvents = True End If End Sub Public Sub ConnMsSQLDatabaseAndUpdate(FieldToUpdate As String, ValueToUpdate As Variant, ID As Integer) Dim conn As ADODB.Connection Set conn = New ADODB.Connection Dim cmd As New ADODB.Command Dim serverName As String Dim databaseName As String Dim SQL As String serverName = "DESKTOP-94N3HCQ\SQLEXPRESS01" databaseName = "ProductInformation" conn.ConnectionString = "driver={SQL Server};server=" & serverName & ";database=" & databaseName conn.ConnectionTimeout = 100 conn.Open If conn.State = 1 Then MsgBox "Database is connected!", vbInformation End If SQL = "Update [ProductInformation].[dbo].Product Set " & FieldToUpdate & "='" & ValueToUpdate & "' Where ID='" & ID & "';" conn.Execute SQL conn.Close MsgBox "The data has been updated.", vbInformation End Sub
@amruthacv2432
@amruthacv2432 7 ай бұрын
@@exceldemy2006 thank you very much 😊 🙏
@exceldemy2006
@exceldemy2006 7 ай бұрын
​@@amruthacv2432 Dear, you are most welcome. Stay connected to ExcelDemy.
@GinaEscalante-th4wi
@GinaEscalante-th4wi 4 ай бұрын
Would it be possible to do this with multiple websites and make one big database?
@exceldemy2006
@exceldemy2006 4 ай бұрын
Dear, Thanks for your question! The answer is YES. You can combine data from multiple websites into one extensive database in Excel that updates automatically. To do so, use the From Web option under the Data tab to connect to each website and load the data into new sheets. Clean the data using the Power Query Editor. Then, use the Append Queries feature to combine all the tables. Import the combined data into your worksheet. To ensure the database updates automatically, enable the auto-update feature by setting a refresh interval in the Connection Properties.
How to Create a Database in Excel with Pictures
19:15
ExcelDemy
Рет қаралды 14 М.
How to Move Data Automatically Between Excel Files
11:37
Kenji Explains
Рет қаралды 175 М.
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 12 МЛН
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 34 МЛН
Ouch.. 🤕⚽️
00:25
Celine Dept
Рет қаралды 33 МЛН
When u fight over the armrest
00:41
Adam W
Рет қаралды 4,5 МЛН
Introducing Python in Excel
19:01
Leila Gharani
Рет қаралды 1,6 МЛН
Excel Database Setup :A Beginner’s Guide to Organizing Data and adding it to the excel data model
18:25
Excel Power Tools: Building a Dynamic Dropdown List From Scratch
8:02
The Practical Place
Рет қаралды 6 М.
EASILY Make an Automated Data Entry Form in Excel
14:52
Kenji Explains
Рет қаралды 781 М.
Searchable Drop Down List in Excel (Very Easy with FILTER Function)
11:00
Creating a Database in Excel [Excel is a Database]
16:35
That Office Guy
Рет қаралды 29 М.
SUPER EASY Excel Data Entry Form (NO VBA)
6:22
Leila Gharani
Рет қаралды 2 МЛН
How To Create A Fillable Form With A Submit Button In Excel
29:20
Melissa Compton
Рет қаралды 154 М.
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 12 МЛН