Excel

Copper Contributor

hi Friends,

 i have following sample data(more than 50000 records are there)

rollnoname
1xya1
2xya2
3xya3
4xya4
5xya5
6xya6
7xya7
8xya8
9xya9
10xya10
11xya11
12xya12
13xya13
14xya14
15xya15
16xya16
17xya17
18xya18
19xya19
20xya20
21xya21
22xya22
23xya23
24xya24
25xya25
26xya26
27xya27
28xya28
29xya29
30xya30
31xya31
32xya32
33xya33
34xya34
35xya35
36xya36
37xya37
38xya38
39xya39
40xya40
41xya41
42xya42
43xya43
44xya44
45xya45
46xya46
47xya47
48xya48
49xya49
50xya50
51xya51
52xya52
53xya53
54xya54
55xya55
56xya56
57xya57
58xya58
59xya59
60xya60
61xya61
62xya62
63xya63
64xya64
65xya65
66xya66
67xya67
68xya68
69xya69
70xya70

 

now  i need to split this into no of pages in same excel per page 25 records automatically with apps script or any other  way, without manual copy paste, without freezing .

rollnoname
1xya1
2xya2
3xya3
4xya4
5xya5
6xya6
7xya7
8xya8
9xya9
10xya10
11xya11
12xya12
13xya13
14xya14
15xya15
16xya16
17xya17
18xya18
19xya19
20xya20
21xya21
22xya22
23xya23
24xya24
25xya25

 

rollnoname
26xya26
27xya27
28xya28
29xya29
30xya30
31xya31
32xya32
33xya33
34xya34
35xya35
36xya36
37xya37
38xya38
39xya39
40xya40
41xya41
42xya42
43xya43
44xya44
45xya45
46xya46
47xya47
48xya48
49xya49
50xya50

 

something above ,   template will be 25 per page  is fixed , with some additional columns. 

1 Reply

@Devender78 assuming all rows are same height and you want 25 rows per page then the easiest is to change the row height so that it automatically paginates accordingly.  You can do that using trial and error or calculate it based on paper size, margins, and row heights (btw better to work in pixels where possible since measurements are rounded).

Alternatively you could use a macro something like this:

Sub print25()
    Dim r1, last As Long
    With ActiveSheet
      last = .UsedRange.Rows.Count
      For r1 = 1 To last Step 25
        .PageSetup.PrintArea = r1 & ":" & r1 + 24
        .PrintOut (ignoreprintareas = False)
      Next r1
    End With
End Sub