Dear all,
I don't manage to combine 2 macros with a certain condition and I've tried various possibilities: for...next , if...Then, if...GoTo, etc.
I just don't get the trick and combine them the way I want.
Here's what the macros should do:
-read in each sheet of workbook between sheet "Template" and sheet "last" the Cell A2
-Cell A2 should always contain a number or nothing
-number rows according to content from Cell A2 , start with 0 in Cell A5 until value of Cell A2 (-1) is reached
-loop to next sheet and start over again
so far so good
Now, I have the problem that there are a few sheets which don't contain anything in Cell A2 and the macro stops.
I tried to somehow tell Excel to go to next sheet if Cell A2 is empty but couldn't find the trick.
Here's what I have so far:
Would someone know how I can combine the macros, so that if it doesn't find anything in Cell A2 it would go to next sheet.Sub LoopThroughSheets() Dim Template As Integer, Last As Integer, I As Integer Template = Sheets("Template").Index Last = Sheets("Last").Index For I = Template + 1 To Last - 1 With Sheets(I) Call performCreateRows End With Worksheets(ActiveSheet.Index + 1).Select line: Next I End Sub Sub performCreateRows() x = ActiveSheet.Range("A2") For j = 1 To x Range("A" & j + 4) = j - 1 Next j End Sub
Something like:
If Range("A2").Value = "" Then
Next I ?????
Many thanks in advance