PrintOut Row selecting problem

holy_eti

New Member
Joined
Jun 5, 2018
Messages
38
Hello, I am working on a code and I would like it to PrintOut some sheets. I want some lines to repeat on each page. My problem is that the row number is a variant so I can't put it in the form :"$7:$8". They are like variant. I've tried many things but none of them seems to be working. Is there special way to declare a variant? Shall my first and second variant be declared as something? I've tried Row but this didnt works

Thank you

Code:
Dim i, a, b, nb_ligne1 As Integer

a = 0
For i = 5 To 12
    nb_ligne1 = Sheets(i).Range("A2").Value
    For b = 6 To nb_ligne1
        Sheets(i).Activate
        If Sheets(i).Cells(b, "I") = "Good" Then
            a = a + 1
        End If
    Next b
    First = a + 7
    second = a + 8
    If nb_ligne1 > 4 Then
        ThisWorkbook.Sheets(i).Activate
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = First & ":" & second
            .PrintTitleColumns = ""
        End With
    End If
Next i
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top