Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Sean Anderson   on Aug 19 In MS Office Category.

  
Question Answered By: Latoya Murray   on Aug 19

So if I get this right.. "These entries  match the names  of the files
in the folder" and "entry = workbookname" ..you're looking to put the
workbook's own file name in a specific  cell?

add the line:
Wkb.Worksheets("Sheet1").Range("aa1") = sFileName

OR:
Wkb.Worksheets("Sheet1").Range("ab1") = Wkb.Name

after:
SourceRange.Copy DestRange

Of course, if the list in column  A is only a subset of the workbooks
you are copying ranges to then you might have to check you've got a
match before copying the single cell  across, in which case instead of
the single line above:

FileNamePresent = False
For Each cll In bWkb.Worksheets("Sheet1").Range("A1:A10")
If cll = sFileName Then FileNamePresent = True
Next cll
If FileNamePresent Then Wkb.Worksheets("Sheet1").Range("c3") =
sFileName

(note I've used A1:A10 above, your range  might be different)

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on loop thorugh a column and copy to matching workbook Or get search suggestion and latest updates.


Tagged: