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 9th, 2002, 02:35 PM   #1
kojak43
Board Regular
 
kojak43's Avatar
 
Join Date: Feb 2002
Posts: 270
Default

A week or so ago Dave Hawley kindly gave me the following code.

On the sheet you wish to enter your data, right click on the sheet name tab, select "view Code" and paste in this


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:Q2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
Sheets("Sheet3").Range(Target.Address) = Target
End If
End Sub


From now on whenever you enter any data on this sheet it within the range "A2:Q1000" it will be automatically mirrored on sheet2 and 3

As it say's it will place all the values from one sheet into two other sheets.

In Sheet 1 the data goes from A2:Q2000. However I only wish to take certain cells from Sheet 1 and place them in Sheet2, and those cells, from sheet1 are not adjacent
I start in A2:A2000, C2:C2000, F2:G2000, J2:O2000 and R2:S2000.

So how can I modify the code to make it work.
What I put in, results in a runtime error 1004. What I did was change A2:Q2000 to read ("Sheet1!A2:A2000, Sheet1C2:C2000") Etc

Any help is greatly appreciated.
K
kojak43 is offline   Reply With Quote
Old Apr 9th, 2002, 02:53 PM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Here's a modification of Dave's code which is what I think you want.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
End If
If Not Intersect(Target, Range("C2:C2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
End If
If Not Intersect(Target, Range("F2:G2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
End If
If Not Intersect(Target, Range("J2:O2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
End If
If Not Intersect(Target, Range("R2:S2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
End If
End Sub

Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 9th, 2002, 05:32 PM   #3
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi K

Tom's method will certainly work but you could simplify it to:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A2000,C2:C2000,F2:G2000,J2:O2000, R2:S2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
Sheets("Sheet3").Range(Target.Address) = Target
End If
End Sub
Dave Hawley is offline   Reply With Quote
Old Apr 9th, 2002, 09:11 PM   #4
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

You know, I tried that Dave and it did not work?
Will copy your code and see if I was doing it wrong...
Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 9th, 2002, 09:13 PM   #5
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Ah. It works!
I was doing it wrong...
If Not Intersect(Target, Range("A2:A2000),Range(C2:C2000), ect...) Is Nothing Then
Tom Schreiner is offline   Reply With Quote
Old Apr 10th, 2002, 10:35 AM   #6
kojak43
Board Regular
 
kojak43's Avatar
 
Join Date: Feb 2002
Posts: 270
Default

Quote:
On 2002-04-09 16:32, Dave Hawley wrote:
Hi K

Tom's method will certainly work but you could simplify it to:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A2000,C2:C2000,F2:G2000,J2:O2000, R2:S2000")) Is Nothing Then
Sheets("Sheet2").Range(Target.Address) = Target
Sheets("Sheet3").Range(Target.Address) = Target
End If
End Sub
Thank you both. I entered the code. I only changed the sheet name to match my existing sheet. I then entered data into Sheet1 and when I went to my sheet, the new data was not there.
I then inserted a new worksheet, named it, and change the code to reflect the new worksheet. I added data to Sheet1 and it added the data to the new sheet.
The data from Sheet1 was non-adjacent cells, that is, A,C,F,G,H ect. And that is how it placed the data in the new worksheet. Which means columns B,D,E were blank.

Oh Geeze, As the late Gilda Radner via Roseanne Rosanna Danna, would say, Never Mind!
I just realized why this did not work how I wished.
This project started with what is now Worksheet2. It had about 100 rows of data. WorkSheet1 evolved as a way to include more information. Part of which would be placed into Worksheet2. However Worksheet1 only has about 30 rows of test data, when I tried to flow it into the other sheet, those rows were filled, so it did not show up.
I have to populate the new sheet1 with all the data from the current sheet2. Then I can begin to added new data in sheet1 and have it move into sheet2.
I am such an idiot!. But thank you both. When I get this sorted out, it is going to be great.
kojak43 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 10:13 AM.


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