Solved

Excel cell change triggers database update

Posted on 2011-09-27
4
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

739 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