vba: paste special problems

M

mbos015

i'm trying to perform a pastespecial inside a loop for opening multipl
files. i.e a as each file is opened i want to copy some cells to th
master.

when i select skipblanks it brings up source data outta range error, o
somethimng like that, ie working on the opened book in the loop stuff
up the pastespecial when u have skipblanks??????

anyway to avoid this, i want to assign a unique name to each book as i
is opened. How do I do that inside a for loop

For f = 1 To UBound(fn)
Workbooks.Open fn(f)
MsgBox ActiveWorkbook.Name, , "Active Workbook Name:"
Staff(f) = ActiveWorkbook.Name ??????????????????

like that, but u get the idea staff1 staff2 staff3...
 
M

mudraker

your code already has the method for setting a workbookname into
variable

Staff(f) = ActiveWorkbook.Name


another option that might help is


Dim fs() As Workbook


redim fs(UBound(fn)

For f = 1 To UBound(fn)
Workbooks.Open fn(f)
MsgBox ActiveWorkbook.Name, , "Active Workbook Name:"
Set fs(f) = ActiveWorkbook


Once fs(f) is set you can refer to it as
fs(f).sheets("Sheet1").cells(1,1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top