ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Excel file multiple opening from a folder problem (https://www.excelbanter.com/excel-programming/277623-vbulletin-excel-file-multiple-opening-folder-problem.html)

icar

VB Excel file multiple opening from a folder problem
 
I am trying to write a macro that will open files one by one from a
folder, do stuff, plot a graph and then save them, close them and open
up the next file. My problem is that the way I have it written , I can
open the first one, do everything, and then once it opens the second
one, it still has the name of the first file as the name of the sheet
shown as the source of the plot. I tried to use .FoundFiles(i) instead
of the actual name but that gave an error. That is how I get to loop
through the files but how can I get it to work for the sheet name. Help
will be appreciated. Thanks,

Icar

This is the part of the code:

ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData
Source:=Sheets("IN-coarse-anm-00001").Range("C1:C31"),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="IN-coarse-anm-00001"
With ActiveChart

Tom Ogilvy

VB Excel file multiple opening from a folder problem
 
Source:=Worksheets(1).Range("C1:C31"),

Might be what you want, but hard to tell with the limited information you
provided.

--
Regards,
Tom Ogilvy

icar wrote in message
...
I am trying to write a macro that will open files one by one from a
folder, do stuff, plot a graph and then save them, close them and open
up the next file. My problem is that the way I have it written , I can
open the first one, do everything, and then once it opens the second
one, it still has the name of the first file as the name of the sheet
shown as the source of the plot. I tried to use .FoundFiles(i) instead
of the actual name but that gave an error. That is how I get to loop
through the files but how can I get it to work for the sheet name. Help
will be appreciated. Thanks,

Icar

This is the part of the code:

ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData
Source:=Sheets("IN-coarse-anm-00001").Range("C1:C31"),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="IN-coarse-anm-00001"
With ActiveChart





All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com