Boa tarde, alexandrevba.
Gostaria de saber se posso trocar "i" de "Dim i" por algum outro caracter, pois na macro que vou usar, conforme o código abaixo, já tem um "Dim i", só que com outros valores.
Olha meu código com adição do seu:
Sub Exibir()
'
' Exibir Macro
'
' Atalho do teclado: Ctrl+Shift+I
'
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="123"
ActiveSheet.Outline.ShowLevels RowLevels:=2
Dim pages As Integer
Dim pageBegin As String
Dim PrArea As String
Dim i As Integer
Dim q As Integer
Dim nRows As Integer, nPagebreaks As Integer
Dim R As Range
Set R = ActiveSheet.UsedRange
'add pagebreak every 40 rows
nRows = R.Rows.Count
If nRows > 40 Then
nPagebreaks = Int(nRows / 35)
For i = 0 To nPagebreaks
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=R.Cells(35 * i + 40, 1)
Next i
End If
'can be used in a separate macro, as I Start counting the number of pagebreaks
pages = ActiveSheet.HPageBreaks.Count
pageBegin = "$A$1"
For i = 1 To pages
If i > 1 Then pageBegin = ActiveSheet.HPageBreaks(i - 1).Location.Address
q = ActiveSheet.HPageBreaks(i).Location.Row - 1
PrArea = pageBegin & ":" & "$H$" & Trim$(Str$(q))
ActiveSheet.PageSetup.PrintArea = PrArea
' the cell in column 1 and in the row immediately below the pagebreak
' contains text for the footer
ActiveSheet.PageSetup.CenterFooter = Cells(q, 1)
' ActiveSheet.PrintOut copies:=1
Next i
Dim i ' AQUI É QUE A COISA COMPLICA
i = 0
Set R = ActiveSheet.UsedRange
nLastRow = R.Rows.Count + R.Row - 2
nFirstRow = R.Row
For n = nFirstRow To nLastRow
If Cells(n, "A").EntireRow.Hidden Then
Else
i = i + 1
End If
Next
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(n, "A")
With ActiveSheet.PageSetup
.Zoom = 70
End With
With ActiveSheet
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
End With
ActiveSheet.Protect Password:="123"
Application.ScreenUpdating = True
End Sub
Se houver duas vezes "Dim i", onde, para cada uma, o valor de "i" é diferente, a macro vai dar erro.
Fico no aguardo.
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 06/03/2012 2:17 pm