Home |
Search |
Today's Posts |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i used F8, and found some strange things... first of all, i keep being asked
that the summary.xls file is already open(which is the file i opened for the list), so what i did was put the summary.xls file into a folder, that makes the macro unable to list that filename... then, the master file, the one with no total value, i made into a hidden attribute.ok. after that, i tried running F8, and it so happens that the first macro runs, but the second, which is the one that's supposed to get the values, doesn't... so i jumped to that line, and started the F8, and it works... so now my problem is, why doesn't the macro run from the first code, to the second code when i open the file? "Joel" wrote: the two subroutines are independant which means myDIR doesn't call Gettotal. Get total must be run by itself. This seems to be the only logically reason for the code not to run except if "grand total" is not on the worksheet. Any other problem would of created an error. Do you see any workbooks openning and closing when the code is running? The default mode for "find" is to ignore case so this isn't the problem. One other possiblity if there are leading or trailing blank in the cell with "grand total". You may want to make the following change. from: Set c = sht.Find(what:="TOTAL", LookIn:=xlValues) to: Set c = sht.Find(what:="TOTAL", LookIn:=xlValues,LookAt:=xlPart) You colud add a break point by click on the different lines in the code and then hitting F9. You can also single step through the code by pressing F8. "Chris" wrote: nothing happened... i changed the code a bit though, since i was using "total" instead of "grand total", and "sheet1" i changed to "production cost", which is my sheet name... nothing happened, the only comforting difference right now is that i don't have to bother putting a "\" after the A1 cell for the first macro to run...? my code now looks like this.... Sub myDIR() myfolder = Range("A1").Value RowCount = 2 First = True Do If First = True Then Filename = Dir(myfolder & "\*.xls") First = False Else Filename = Dir() End If If Filename < "" Then Range("A" & RowCount) = Filename RowCount = RowCount + 1 End If Loop While Filename < "" End Sub Sub Gettotals() myfolder = Range("A1").Value With ThisWorkbook.ActiveSheet LastRow = .Cells(Rows.Count, "A").End(xlUp).Row Set FileNames = .Range("A2:A" & LastRow) End With For Each Cell In FileNames Workbooks.Open Filename:=myfolder & "\" & Cell Set sht = ActiveWorkbook.Sheets("Sheet1").Cells Set c = sht.Find(what:="TOTAL", LookIn:=xlValues) If Not c Is Nothing Then total = c.Offset(rowoffset:=0, columnoffset:=1) Cell.Offset(rowoffset:=0, columnoffset:=1) = total End If ActiveWorkbook.Close Next Cell End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CELL("filename") doesn't work on shortcut workbook link? | Excel Worksheet Functions | |||
vba, get filename of this workbook | Excel Discussion (Misc queries) | |||
reutrn a value from a cell in each workbook filename from another | Excel Programming | |||
Cell("filename") doesn't update to new filename when do save as. | Excel Worksheet Functions | |||
My workbook filename | Excel Programming |