insert table into specific location

F

Forgone

I need a point in the right direction.

I've got a series of workbooks that I need to paste a specific table
into on an activesheet. The table is located in the personal.xls file
which I've given it a name (let's call it..... table.to.insert)

All I want to achieve is with the activesheet I'm on. unprotect the
sheet, copy (table.to.insert) and paste it the active sheet in the
range B24.

I tried recording a macro and manipulate it but I couldn't get it to
copy from the personal.xls file into another worksheet. I've even
tried having the table in a seperate worksheet (closed) but that
didn't work out as planned either.

Trying to simplify it.

Source: table.to.insert (can be located anywhere, doesn't have to be
personal.xls)
Target: activesheet | range B24

Copy from source, go to activesheet, unprotect, paste and retain
everything.
 
D

Dave Peterson

Option Explicit
Sub testme()

Dim RngToCopy As Range
Dim DestCell As Range

Set RngToCopy = Workbooks("Personal.xls").Worksheets("somesheetnamehere") _
.Range("table.to.insert")

Set DestCell = ActiveSheet.Range("B24")

With DestCell
.Parent.Unprotect
RngToCopy.Copy _
Destination:=.Cells
.Parent.Protect
End With

End Sub
 
F

Forgone

Option Explicit
Sub testme()

    Dim RngToCopy As Range
    Dim DestCell As Range

    Set RngToCopy = Workbooks("Personal.xls").Worksheets("somesheetnamehere") _
                      .Range("table.to.insert")

    Set DestCell = ActiveSheet.Range("B24")

    With DestCell
        .Parent.Unprotect
        RngToCopy.Copy _
            Destination:=.Cells
        .Parent.Protect
    End With

End Sub












--

Dave Peterson- Hide quoted text -

- Show quoted text -

Fantastic... thanks heaps......
 

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