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 Apr 10th, 2002, 02:22 AM   #1
torbjoen
New Member
 
Join Date: Apr 2002
Posts: 5
Default

Hi!

I'm new to Visual Basic and Macros in Excel, but I've experimented a few hours now.

I'd like to make a graph out of a single column, and display it in the same worksheet as the datasource. This will be repeated for several worksheets.

This is my code (which does not work as I'd like):
/***************************/
Sub Macro6()
'
' Macro6 Macro
' Macro recorded 10.04.02 by student
'

'
Range("B2:B202").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("1000mm_auto_(2)").Range("B2:B202")
ActiveChart.Location Where:=xlLocationAsObject, Name:="1000mm_auto_(2)"
End Sub
/********************************/

This macro always refers to the same worksheet, but I'd like to do the similar action on different sheets, placing the graphs in the correct sheets.

Also, I'd like to make a scatter diagram: think of a the position of a mouse on the screen. Once each millisecond, the position of the mouse is recorded. Then, after recording posistions in two seconds, I would like to display a scatter diagram of where the mouse has been moving, using the width and height of the screen as x- and y- axis on the scatter diagram. How can I do this? I've got one coloumn of each of the x- and y-positions, and would like to display this in a sensible manner.

Thanks, folks

[ This Message was edited by: torbjoen on 2002-04-10 01:27 ]
torbjoen is offline   Reply With Quote
Old Apr 10th, 2002, 02:55 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

This should solve your first problem:

Sub Macro6()
Dim PlaceChartHere As String
' Macro6 Macro
' Macro recorded 10.04.02 by student
'

PlaceChartHere = ActiveSheet.Name
'Range("B2:B202").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("1000mm_auto_(2)").Range("B2:B202")
ActiveChart.Location Where:=xlLocationAsObject, Name:=PlaceChartHere
End Sub

Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 10th, 2002, 03:01 AM   #3
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

As for the second question....
It's too late for me to try this one.
My first thought would be to draw an image covering the whole screen, make it invisible, group it to the highest layer, and manipulate your chart coordinates via the image1 mouse move event???
Try it out.
Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 10th, 2002, 03:25 AM   #4
torbjoen
New Member
 
Join Date: Apr 2002
Posts: 5
Default

Thanks, Tom

My first problem:
Doesn't this sentence also have to be changed in some way?:
/*****************/
ActiveChart.SetSourceData Source:=Sheets("1000mm_auto_(2)").Range("B2:B202")
/*****************/

Guess maybe I can do something like what you've done on top of the function?

I think I made a bad explanation of my second problem: It is not necessary to have the entire graph as large as the screen. Actually I just need the values on the scatter diagram to be the same value as the height and the width of the screen. The graph does not have to cover the screen - I only need to put it into my worksheet.

Thanks, again!
torbjoen is offline   Reply With Quote
Old Apr 10th, 2002, 03:36 AM   #5
torbjoen
New Member
 
Join Date: Apr 2002
Posts: 5
Default

My problem 1 works like a charm using:

/*************************/
Dim PlaceChartHere As String
PlaceChartHere = ActiveSheet.Name
'Range("B2:B202").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets(PlaceChartHere).Range("B2:B202")
ActiveChart.Location Where:=xlLocationAsObject, Name:=PlaceChartHere
/*********************************/

Torbjørn
torbjoen is offline   Reply With Quote
Old Apr 10th, 2002, 03:39 AM   #6
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi
If I understood you correctly, the chart location was to placed on the active sheet?
The source data is also to be on the active sheet?
If so, change to:
ActiveChart.SetSourceData Source:=Sheets(PlaceChartHere).Range("B2:B202")

As for the mouse chart. The image would cover the whole screen, not the chart.
You could use the mouse move event tp track the x,y coordinates if I understand what you are trying to accomplish...


Tom

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:03 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