Hi, I'm trying to make a macro run on every sheet in my workbook, problem is macro doesn't work if cell value is 0:
I tried to loop it using:
But it only runs on the active worksheet, not on the whole workbook, so I've got two problems:
1) Every sheet has a Name on B1 and Number of Payments on cell B1, I only need to run the macro on sheets that have a number of payments greater than 0
2) First sheet named "ACUMULADOS" has a summary table of every payment, so I also need to exclude the macro from running on this sheet.
Thanks, any help is appreciated.
VBA Code:
Sub Ola()
Dim Rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Range("A1:B1")
Set OutRng = Range("B3")
Set OutRng = OutRng.Range("A1")
For Each Rng In InputRng.Rows
xValue = Rng.Range("A1").Value
xNum = Rng.Range("B1").Value
OutRng.Resize(xNum, 1).Value = xValue
Set OutRng = OutRng.Offset(xNum, 0)
Next
End Sub
I tried to loop it using:
VBA Code:
Sub manekankit()
Dim Ws As Worksheet
For Each Ws In ActiveWorkbook.Worksheets
If Ws.Range("B1").Value > 0 Then
Ola
End If
Next Ws
End Sub
But it only runs on the active worksheet, not on the whole workbook, so I've got two problems:
1) Every sheet has a Name on B1 and Number of Payments on cell B1, I only need to run the macro on sheets that have a number of payments greater than 0
2) First sheet named "ACUMULADOS" has a summary table of every payment, so I also need to exclude the macro from running on this sheet.
Thanks, any help is appreciated.