ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   insert table into specific location (https://www.excelbanter.com/excel-programming/420485-insert-table-into-specific-location.html)

Forgone

insert table into specific location
 
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.

Dave Peterson

insert table into specific location
 
Option Explicit
Sub testme()

Dim RngToCopy As Range
Dim DestCell As Range

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

Set DestCell = ActiveSheet.Range("B24")

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

End Sub


Forgone wrote:

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.


--

Dave Peterson

Forgone

insert table into specific location
 
On Nov 25, 9:43*pm, Dave Peterson wrote:
Option Explicit
Sub testme()

* * Dim RngToCopy As Range
* * Dim DestCell As Range

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

* * Set DestCell = ActiveSheet.Range("B24")

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

End Sub





Forgone wrote:

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.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


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


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com