finaljustice
Board Regular
- Joined
- Oct 6, 2010
- Messages
- 175
Hello, i'm quite new to VBA and I am trying to develope a macro that updates a specific workbook.
There are two questions I would like to ask,
1) How to Select 4 (or more) sheets which their names were saved as variables.
Eg. Sheets(Array("var1","var2","var3","var4")).Select
Where Var1, Var2, Var3 are variable which got their values from cells. (This I know how to do)
Could this be done by using a Array variable, if so could it look something like: (lets say my array variable is Avar() )
Sheets(Avar()).select
2)
I've explained what my problem is within the code.
So basically that is my issue, once vba opens the new workbook it becomes the active workbook and the macro stops runing. I wish to know, how do I make Vba open this new workbook and continue running the macro.
Thank you very much for your attention and help, this will greatly help me.
Yours sincerely,
final
There are two questions I would like to ask,
1) How to Select 4 (or more) sheets which their names were saved as variables.
Eg. Sheets(Array("var1","var2","var3","var4")).Select
Where Var1, Var2, Var3 are variable which got their values from cells. (This I know how to do)
Could this be done by using a Array variable, if so could it look something like: (lets say my array variable is Avar() )
Sheets(Avar()).select
2)
I've explained what my problem is within the code.
Code:
Sub AtualizarForecast()
Sheets(1).Select
Range("H4").Select
Do While ActiveCell <> Empty 'list of names of workbooks that must be opened
NomeSuperint = ActiveCell.Value 'Name of the workbooks that must be opened
MsgBox "Selecione a pasta para o arquivo: " & NomeSuperint 'shows the user what workbook must be "opened"
DiretForecast = Application.GetOpenFilename
Application.Workbooks.Open (DiretForecast) 'opens work
'now here is where I am stumbling, once it gets to this point the newly opened workbook stops the macro. I need to copy information from the opened workbook and paste it back on the first workbook
Sheets(1).Select
Range("C15").Select
Range(ActiveCell, Cells(ActiveCell.Row, 256).End(xlToLeft)).Copy
ActiveCell.Offset(1, 0).Select
Loop
End Sub
So basically that is my issue, once vba opens the new workbook it becomes the active workbook and the macro stops runing. I wish to know, how do I make Vba open this new workbook and continue running the macro.
Thank you very much for your attention and help, this will greatly help me.
Yours sincerely,
final