Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel cell change triggers database update

Posted on 2011-09-27
4
Medium Priority
?
289 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 1332 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 1332 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 668 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

972 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