Copy a any excel range from one workbook to another workbook into a different range – openpyxl, python

I have some excel data that I would like to copy a range of cell values from one sheet and paste them into another workbook/sheet/any range that I select. I have the openpyxl workbook assignments working as well as selecting a range to copy. But, my copy will only paste in the same range area that it started in the source workbook. I would like to select a different paste range. Also a range can be as big or small as you select.

I have tried several other post listed here however none really point a way to change the destination range area or allow you to select where you want to place the selected range. I do feel like I will need another FOR loop to the pasting process but not sure how to write it out. I would appreciate any help on this.
Example operation

Excel Sheet Source                   Excel Sheet Destination
  A   B                                A   B   C   D   E
1 a   e                              1
2 b   f                              2
                                     3             a   e 
                                     4             b   f

Code sample

import os
import openpyxl as xl
from openpyxl.utils import rows_from_range

#Assign Folder & Files variables
desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')

practicefolder = 'Practice'
source_file = 'source_file.xlsx'
destination_file = 'destination_file.xlsx'


# opening the source excel file
filename = (desktop + '\' + practicefolder + '\' + source_file)
wb1 = xl.load_workbook(filename)
ws1 = wb1.worksheets[0]

# opening the destination excel file
filename1 = (desktop + '\' + practicefolder + '\' + destination_file)
#dest = 'dest_sheet2'                          #For assigning different sheet
wb2 = xl.load_workbook(filename1)
ws2 = wb2.active

#Selecting the copy range below
range_str = 'A1:B2'                            #Select copy range

src = ws1
dst = ws2
for row in rows_from_range(range_str):
    for cell in row:
        dst[cell].value = src[cell].value




wb2.save(str(filename1))

3

To expand a bit on my comment you can include the calculation of the offsets in the code.
Example rather than work out that the row and column offsets needed are 2 and 3 respectively we can just enter the cell coordinate of the new location ‘D3’ and have the code calculate this.
In the code sample below I have included a new variable dst_top_left which is the top left cell where the source data is to be copied. In your example this is ‘D3’. The code then determines the row offset is 2 and the column offset is 3 and sets these when copying the data.
The copy only migrates the cell values no cell formatting is copied.
Note there is an extra import at the top of the code sample, then unchanged code in the middle is not displayed.

from openpyxl.utils.cell import coordinate_to_tuple as ctt

...

# opening the source excel file
filename = (desktop + '\' + practicefolder + '\' + source_file)
wb1 = xl.load_workbook(source_file)
src = wb1.worksheets[0]

# opening the destination excel file
filename1 = (desktop + '\' + practicefolder + '\' + destination_file)
# dest = 'dest_sheet2'                          #For assigning different sheet
wb2 = xl.load_workbook(destination_file)
dst = wb2.active

# Selecting the copy range below
range_str = 'A1:B2'  # Select copy range
### Set the top left cell of the destination range
dst_top_left = 'D3'

### Get a tuple of the difference between the src top left and dst top left
diff = tuple(x-y for x, y in zip(ctt(dst_top_left), ctt(range_str.split(':')[0])))

cr = CellRange(range_str)

for row in src.iter_rows(max_col=cr.max_col, min_col=cr.min_col, max_row=cr.max_row, min_row=cr.min_row):
    for cell in row:
        ### Copy src cell value to the dst cell
        dst[cell.coordinate].offset(row=diff[0], column=diff[1]).value = cell.value

wb2.save(destination_file)

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật