copy the valued of named ranges



There are 2 workbooks. I want Book1 to open Book2. I want to loop through
all of the named ranges in Book1!Sheet1. Everytime that named range also
exists in Book2!Sheet2, I want to copy the value of that named range on
Book2!Sheet2 into Book1!Sheet1.

am i making any sense?

thanks in advance!


Thanks for the Response!

but is there a way i can contain this just in my code? below i explain how
i thought the code would flow. I'm just not sure how to code it correctly.

this code woudl be triggered by the user pressing a button:

For Each name in thisworkbook.worksheets("test").names
if this name also exists on book2.worksheets("test") Then
pass the value of the name in book2 to the value of name in
'do nothing...(skip this name)
end if
next name


Steve -

Here is some sample code to get you going:

On Error Resume Next

For Each Name In ThisWorkbook.Sheets("Test").Names
WB1Name = Name.Name
WB2Name = Workbooks("Book2.xls").Sheets("Test").Names(WB1Name).Name

If WB1Name = WB2Name Then
ActiveCell.Value = WB2Name
ActiveCell.Offset(0, 1).Value =
ActiveCell.Offset(1, 0).Select
End If

Next Name

On Error Goto HandleErr '<<< puts code back to your error handler (where
HandleErr is the name of your error handler)

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