Solved

Excel cell change triggers database update

Posted on 2011-09-27
4
264 Views
Last Modified: 2012-05-12
Hello

I have a spreadsheet with about 1,000 rows in it—essentially it’s all appointment information (dates/times, appointment #, etc.)

We need to trigger an update to a database table if certain cells within a column on this spreadsheet have changed.  Only if a change is made to the cells would the database
update happen.

Can you please show me the vba syntax to accomplish this?  

Thank you for your help and time.
0
Comment
Question by:cjb123
  • 2
4 Comments
 
LVL 7

Assisted Solution

by:m4trix
m4trix earned 333 total points
ID: 36713854
Here's an example showing how to do something when a cell changes. Because it will run every time ANY cell changes, you need to put rules around which cells/columns/rows are the ones you want to watch. For example, to create a pop up any time a cell in column "B" changes, use this code on the sheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 Then
        MsgBox "A Cell (" & Target.Address & ") has been changed"
    End If
End Sub

Open in new window


A working example document is here:
 cellchange.xlsm

If you were looking for "vba syntax" for the entire process - ie updating your database, you'd have to give a bit more information about the kind of database you're using and how you access it
0
 

Author Comment

by:cjb123
ID: 36713965
Thanks Matrix.

Here is more context  in order to flesh these needs in greater detail:

1. We're planning to update a SQL Server database table using a login & password configured to allow updates only to certain tables which our DBA will setup for us.

2. The idea of a pop-up window is a good one-- but we could have dozens (or hundreds) of updates to make and this pop-up could get in the way.

Does this provide more concrete here?

Thank you
0
 
LVL 7

Accepted Solution

by:
m4trix earned 333 total points
ID: 36714053
Well, the pop up was meant more as an example to show how it was working. I wouldn't expect it to be in a final solution.

As for the database updating portion I'm not that familiar with using SQL Server so I'll defer to others on this board for that. If there are no updates to this post tomorrow morning I'll see what I can come up with for you
0
 
LVL 7

Assisted Solution

by:Eoin Ryan
Eoin Ryan earned 167 total points
ID: 36813802
without the database specifics you won't get a full answer as to update the database will require a specific table and field name in that database.

As a side, having 2 versions of the data (database and excel sheet) can lead to trouble. If possible I'd aim for a database orientated means of checking and updating your entries.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question