2016 Aug 09 7:28 AM
Hi all,
I have been trying to get the following autofill functionality to work, but with no success yet,
Here is the recorded clip,
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E10")
How do I pass the range to the AutoFill? I have the range area in variables.
Br,
Pekka
2016 Aug 09 9:18 AM
Hi,
In order to use AutoFill method, you need two range objects; Destination & Source. I think below example will help you to solve the problem.
DATA: ls_cellbgn TYPE ole2_object,
ls_cellend TYPE ole2_object,
ls_src_range TYPE ole2_object,
ls_des_range TYPE ole2_object.
" Select Source Range
CALL METHOD OF worksheet 'Cells' = ls_cellbgn
EXPORTING
#1 = 1 " Source Begin row
#2 = 1. " Source Begin column
CALL METHOD OF worksheet 'Cells' = ls_cellend
EXPORTING
#1 = 1 " Source End row
#2 = 1. " Source End column
CALL METHOD OF worksheet 'Range' = ls_src_range
EXPORTING
#1 = ls_cellbgn
#2 = ls_cellend.
" Select Destination Range
CALL METHOD OF worksheet 'Cells' = ls_cellbgn
EXPORTING
#1 = 1 " Destination Begin row
#2 = 1. " Destination Begin column
CALL METHOD OF worksheet 'Cells' = ls_cellend
EXPORTING
#1 = 10 " Destination End row
#2 = 1. " Destination End column
CALL METHOD OF worksheet 'Range' = ls_des_range
EXPORTING
#1 = ls_cellbgn
#2 = ls_cellend.
" AutoFill
CALL METHOD OF ls_src_range 'AutoFill'
EXPORTING
#1 = ls_des_range
#2 = 0. " xlFillDefault
e.g. With the help of source range, you can also use the Auto increment property of AutoFill.
Thanks,
Zafer
Hi all,
I have been trying to get the following autofill functionality to work, but with no success yet,
Here is the recorded clip,
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E10")
How do I pass the range to the AutoFill? I have the range area in variables.
Br,
Pekka
2016 Aug 09 9:18 AM
Hi,
In order to use AutoFill method, you need two range objects; Destination & Source. I think below example will help you to solve the problem.
DATA: ls_cellbgn TYPE ole2_object,
ls_cellend TYPE ole2_object,
ls_src_range TYPE ole2_object,
ls_des_range TYPE ole2_object.
" Select Source Range
CALL METHOD OF worksheet 'Cells' = ls_cellbgn
EXPORTING
#1 = 1 " Source Begin row
#2 = 1. " Source Begin column
CALL METHOD OF worksheet 'Cells' = ls_cellend
EXPORTING
#1 = 1 " Source End row
#2 = 1. " Source End column
CALL METHOD OF worksheet 'Range' = ls_src_range
EXPORTING
#1 = ls_cellbgn
#2 = ls_cellend.
" Select Destination Range
CALL METHOD OF worksheet 'Cells' = ls_cellbgn
EXPORTING
#1 = 1 " Destination Begin row
#2 = 1. " Destination Begin column
CALL METHOD OF worksheet 'Cells' = ls_cellend
EXPORTING
#1 = 10 " Destination End row
#2 = 1. " Destination End column
CALL METHOD OF worksheet 'Range' = ls_des_range
EXPORTING
#1 = ls_cellbgn
#2 = ls_cellend.
" AutoFill
CALL METHOD OF ls_src_range 'AutoFill'
EXPORTING
#1 = ls_des_range
#2 = 0. " xlFillDefault
e.g. With the help of source range, you can also use the Auto increment property of AutoFill.
Thanks,
Zafer
2016 Aug 09 9:35 AM
Hello Zafer,
Works like charm
Thanks a lot. Much faster write cell by cell...
Br,
Pekka
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |