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 8th, 2002, 10:21 AM   #1
ArchiEMS
New Member
 
Join Date: May 2002
Location: Charleston,sc
Posts: 9
Default

Alright, I've hit the wall, I have been looking thru the board for about a week and found someone with a similar problem to mine. I want to copy a block of cells from different files, which are closed, to one file so I can do some analysis of this file.(I want to create a phantom master file of the others, so I can extract data and use it in analysises). That being said I have used a macro from here and modified it for my purposes. But, It will only copy the block of cells from the first sheet correctly and places "#Value" in the other cells from the other sheets. I have verified the "#Value" cells are coming from the other sheets but are not displaying the data. If anyone is up for the problem, let me know and I can post the code.

Thank you,
EMS
ArchiEMS is offline   Reply With Quote
Old May 8th, 2002, 10:22 AM   #2
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Post away!
kkknie is offline   Reply With Quote
Old May 8th, 2002, 10:24 AM   #3
ArchiEMS
New Member
 
Join Date: May 2002
Location: Charleston,sc
Posts: 9
Default

Sub expermient6()
Dim sdir As String
Dim Datarg As Range
Dim myCells As String
Dim Files
Dim x As Variant
'This is the directory being searched
sdir = "c:My DocumentsECMAC Analysis"
' Location of the cells on sheet 1
myCells = "Sheet1'!$A$7:$G$21"
Files = Dir(sdir & "*.xls")
'Speeding things up
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
x = 7
On Error GoTo FileError
Do While Len(Files) > 0
Range("A" & x, "G" & (x + 15)) = "='" & sdir & "[" & Files & "]" & myCells
Set Datarg = Range("A7", "G" & (x + 15))
x = x + 15
Files = Dir()
'Copying now
Application.Calculate
Datarg.Copy
Datarg.PasteSpecial
Loop
Application.CutCopyMode = False
Set Datarg = Nothing
Application.Calculation = xlCalculationAutomatic
Application.Calculate
Application.ScreenUpdating = True
Exit Sub
ArchiEMS is offline   Reply With Quote
Old May 8th, 2002, 10:56 AM   #4
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

I've got an hour long+ meeting in a few minutes, but here's what I've seen.

It appears that when the formula:

='D:[Book1.xls]Sheet1'!$A$7:$G$21

is in the same range on the new sheet as it is on Book1.Sheet1, all is OK. When the new sheet range changes, you get the errors.

I created two dummy workbooks to search through and filled Sheet1 on both with a bunch of data. If I change the formula for
Book2 to

='D:[Book1.xls]Sheet1'!$A$22:$G$37, it pulls in the data from those cells.

I'll be out of pocket for a while, but in any case, I am not sure what the heck is happening. I'll make another attempt when I get back in.

Good luck,

K
kkknie is offline   Reply With Quote
Old May 8th, 2002, 11:06 AM   #5
ArchiEMS
New Member
 
Join Date: May 2002
Location: Charleston,sc
Posts: 9
Default

Thanks for the effort, I think I will be working on it for a while so if you have any thought later let me know. In the mean time I will exlpore you idea, I haven't noticed that to this point yet.

Thanks,
EMS
ArchiEMS is offline   Reply With Quote
Old May 8th, 2002, 11:51 AM   #6
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Aha!!!

I've done it quite a bit differently, but it does seem to work. The only question is whether you want to keep the references or the values in the new workbook. My way keeps the references, but if you want actual values, it would be simple to select the new range and copy, paste special values.

Here it is:

Sub expermient()

Dim Files
Dim strCol As String
Dim intRow As Integer
Dim sdir As String
Dim x As Integer
Dim tempStr As String

Sheets(1).Select

'Directory to be searched
sdir = "d:"

'Offset
x = 6

Files = Dir(sdir & "*.xls")

Do While Len(Files) > 0

For i = 1 To 15
For j = 1 To 7

tempStr = Chr(64 + j) & i + x
Cells(i + x, j).Value = "='" & sdir & "[" & Files & "]Sheet1'!" & tempStr
Next
Next

x = x + 15
Files = Dir()

Loop

End Sub

Let me know if you need any clarification.

K
kkknie is offline   Reply With Quote
Old May 8th, 2002, 01:14 PM   #7
ArchiEMS
New Member
 
Join Date: May 2002
Location: Charleston,sc
Posts: 9
Default

Alright it's getting close and the code is definately shorter than mine. It's returning numbers and getting them from the various files but it's still just keeping the order. I need to get A7:G21 of all sheets(eventually there will be 144 sheets) and put them in columns A7:G"whatever is needed". It's now taking A7:G21 from the first file then taking A21:G35 from the next and so on... But I am getting numbers from the other sheets now, but it's just zeros. Any Ideas?
ArchiEMS is offline   Reply With Quote
Old May 8th, 2002, 02:50 PM   #8
ArchiEMS
New Member
 
Join Date: May 2002
Location: Charleston,sc
Posts: 9
Default

WHOOO HOOO!!! I got it to work. Thank you so much for your help K. The x was on both sides of the equation basically. I just replaced 6 for x in the tempStr. By the way if you have time what does "Chr(64+j) & i+6" do anyway. Once again thanks for your help and this board is awesome!!!!!!!!

thanks,
ems
ArchiEMS 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 12:36 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