Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel cell change triggers database update

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 how to use a scrolling table in Microsoft Excel using the INDEX function.

705 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