Solved

Excel cell change triggers database update

Posted on 2011-09-27
4
236 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 6

Assisted Solution

by:EoDawg
EoDawg 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now