Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Ole2 & AutoFill

pekka_pottonen
Participant
0 Likes
796

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

1 ACCEPTED SOLUTION
Read only

zaferonbas
Participant
0 Likes
727

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 = " 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

2 REPLIES 2
Read only

zaferonbas
Participant
0 Likes
728

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 = " 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

Read only

0 Likes
727

Hello Zafer,

Works like charm

Thanks a lot. Much faster write cell by cell...

Br,

Pekka