VBA question please

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi everyone,

Say I have this VBA piece of code:

For JobNr = 1 To 25
Aline = 1
For Each mac In vehicleModel.Macros
If mac.Value <> 0 Then
Flag = 1
ARngSolution(JobNr, Aline).Value = mac.Value
With ARngSolution(JobNr, Aline)
.HorizontalAlignment = xlCenter
.NumberFormat = "#.##0"
End With
Aline = Aline + 1
End If
Next mac

For every "JobNr", a data row is written. Now, if the above condition,
i.e. (mac.Value<>0), is not satisfied, I don't want the data's row for
that "JobNr" to be left blank, but to go to the next "JobNr" and write
its related data's row if the condition is satisfied.

So, in a 25 runs, it might end up with 20 data's rows for example with
no blank row inbetween.

What should I add to let the above piece do so?

Thanks,
Mike
 
Mike

Use another variable like your Aline and don't include JobNr in your range
reference
:
For JobNr = 1 To 25
Aline = 1 Bline = 1
For Each mac In vehicleModel.Macros
If mac.Value <> 0 Then
Flag = 1
'ARngSolution(JobNr, Aline).Value = mac.Value
ARngSolution(Bline,Aline).Value = mac.Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top