MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 4th, 2002, 12:24 AM   #1
mcleve
New Member
 
Join Date: May 2002
Posts: 25
Default

Hi,

Maybe you can help me out with excel. Im using a dde topic to fill cell A1 with a number, 155 for instance. I need to send this value to cell B1 "155". When cell A1 changes "105" i need the new value to go to cell B1"105". And the old B1 value to go to B2 "155". When cell A1 changes again "215" I want the new value to go to Cell B1 "215" and the old B1 data to go to B2 the old B2 data to go to B3 "155" and so on. Any idea how I can accomplish this?

A1 215 B1 215
B2 105
B3 155

Each time A1 changes I need all the data in column B to shift down and insert the new data from A1 on top, leaving the oldest data at the bottom of the column and the newest data at the top.

I could even put the first data in b1 the next in b2 then b3 and so on but the data has to come from A1 and move this data automatically.

Thank you so much for your help,
Marty Clevenger

[ This Message was edited by: mcleve on 2002-05-19 19:26 ]
mcleve is offline   Reply With Quote
Old May 4th, 2002, 01:31 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Are you talking about Dynamic Data Exchange(DDE Linking)?
I will wait for your reply because my answer to you will vary if you are using DDE.
Thanks,
Tom
Tom Schreiner is offline   Reply With Quote
Old May 4th, 2002, 08:54 AM   #3
mcleve
New Member
 
Join Date: May 2002
Posts: 25
Default

Yes Dynamic Data Exchange entry in cell A1.
mcleve is offline   Reply With Quote
Old May 4th, 2002, 09:01 AM   #4
XiniX
Board Regular
 
Join Date: May 2002
Location: Nederland
Posts: 57
Default

try control-shift-=
choose one option and you are done
XiniX is offline   Reply With Quote
Old May 4th, 2002, 09:06 AM   #5
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

In a sheet module (not a regular code module), enter the following

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(False, False) = "A1" Then
        Range("B1").Insert Shift:=xlDown
        Range("B1") = Target
    End If
End Sub
TsTom -- I would really like to learn about the DDE linking, so please post your reply. I've never heard of it.

Worksheet events can be messy, and if A1 changes through formula, this won't work without modification. It seems that you know a better way. That would be great to know.

[ This Message was edited by: Jay Petrulis on 2002-05-04 08:18 ]
Jay Petrulis is offline   Reply With Quote
Old May 4th, 2002, 09:11 AM   #6
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

What is the frequency of your updates?

Do you leave the workbook open and wish to have this automated? Or simply updated as
the link is refreshed and when the workbook is initially opened?

The reason I'm asking is this...
The change event is not fired when a dde link is refreshed. You will need to link cell A1 to another cell and capture the update via the calculation event. If you are not famiiliar with VBA, do not be wearied by my explanation. It is a very simply problem to solve if all you are needing is what was described in your initial post.

When these questions are answered, I or some-one else can paste the code in here or you can email the workbook, I'll code it out, and send it back...
Tom
Tom Schreiner is offline   Reply With Quote
Old May 4th, 2002, 09:15 AM   #7
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

DDE is basically a second choice to Ole automation. Kind of a handshake between two applications. Many apps support it. Ole is much easier to use for us programmers, less demanding of resources, and faster as well. Go to MSDN and check it out if you'd like.
There's bound to be some info there.
Tom
Tom Schreiner is offline   Reply With Quote
Old May 4th, 2002, 09:19 AM   #8
mcleve
New Member
 
Join Date: May 2002
Posts: 25
Default

A1 is updated when the operator of a machine presses the stop button on the machine. this data is gathered by a PLC (Programmable Logic Controller) and interfaced by RSlinx. I create a served DDE Topic in Rslinx to excel. When the operator presses stop A1 will get the current time ie. 12:21:15 AM. When the operator presses start the current time will be logged again to A1. A1 will be updated whenever the operator presses the start or stop button.
mcleve is offline   Reply With Quote
Old May 4th, 2002, 09:24 AM   #9
mcleve
New Member
 
Join Date: May 2002
Posts: 25
Default

Do you leave the workbook open and wish to have this automated? Or simply updated as
the link is refreshed and when the workbook is initially opened?

Update when the value in A1 changes and when the workbook is initially opened.
mcleve is offline   Reply With Quote
Old May 4th, 2002, 09:28 AM   #10
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Insert this formula in cell A2
=A1
Right-click on your worksheet tab
and choose view code.
Paste this code in...(thanks for the code Jay)



Private Sub Worksheet_Calculate()
Application.EnableEvents = False
If Range("A2") <> OldValueInA1 Then
Range("B1").Insert Shift:=xlDown
Range("B1") = Range("A1")
OldValueInA1 = Range("A1")
End If
Application.EnableEvents = True
End Sub



Close the code window...

Right-click on the Excel icon
immediately left of the File menu item.
Choose view code, paste this in.



Private Sub Workbook_Open()
OldValueInA1 = Range("A1")
End Sub




At the menu bar up top, choose insert,
module.
Paste this in this module:



Public OldValueInA1



That should square you up...
Post again if any problems.
Tom

[ This Message was edited by: TsTom on 2002-05-04 08:31 ]
Tom Schreiner is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes