# help in macro_newbie

#### Mabangiz32

##### New Member
this is from the macro that i am using for optimization.
need help because when i start the macro it would count 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 and so on.
i cannot find out how number 10 is not showing,

thanks for the help.

*macro

'Stampanje oznake sipke npr.A, B, C...itd.
slova = "123456789"
Range("f14").Value = "Bar"
Dim rowCnt As Integer, cntLevel1 As Integer, cntLevel2 As Integer
rowCnt = 0
cntLevel1 = -1
cntLevel2 = -1
Dim id As String
For i = 0 To komada - 1
id = ""
If cntLevel2 > -1 Then id = id + Mid(slova, cntLevel2 + 1, 1)
If cntLevel1 > -1 Then id = id + Mid(slova, cntLevel1 + 1, 1)

ActiveCell.Offset(i, 4).Value = id + Mid(slova, rowCnt + 1, 1)
rowCnt = rowCnt + 1
If rowCnt >= 10 Then
cntLevel1 = cntLevel1 + 1
rowCnt = 0
If cntLevel1 >= 10 Then
cntLevel2 = cntLevel2 + 1
cntLevel1 = 0
End If
End If
Next i

thanks for the help..

### Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

#### Joe4

Welcome to the Board!

need help because when i start the macro it would count 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 and so on.
i cannot find out how number 10 is not showing,

I have no idea what you macro is supposed to be doing (you haven't explained that part), but I do notice one thing.
It seems that it is looping through this string of numbers:
Code:
``[COLOR=#333333]slova = "123456789"[/COLOR]``
Notice that "0" is not in that string, and the number "10" has a 0 in it.
So I suspect that has something to do with it.

#### Mabangiz32

##### New Member
yes, you are correct, my problem is the looping.
number 10 is not showing and when it reach 19 20 would not show.

1.
2.
3.
4.
5.
6.
7.
8.
9.

11.
12.
13.
and so on.

can't figure what i am missing.

thank you for helping me out.

#### Joe4

can't figure what i am missing.
I mentioned what I think the problem is.
What happens if you change:
Code:
``[COLOR=#333333]slova = "123456789"[/COLOR]``
to
Code:
``[COLOR=#333333]slova = "1234567890"[/COLOR]``

If that does not fix it, please post the rest of the code associated with this.
I think you have left information off, as you are using a variable named "komada" that is not declared or set anywhere in the code you posted.

#### Mabangiz32

##### New Member
i am back, sorry about yesterday.

this is what i did as per your instruction.

slova = "1234567890"
Range("f14").Value = "Bar"
Dim rowCnt As Integer, cntLevel1 As Integer, cntLevel2 As Integer
rowCnt = 0
cntLevel1 = -1
cntLevel2 = -1
Dim id As String
For i = 0 To komada - 1
id = ""
If cntLevel2 > -1 Then id = id + Mid(slova, cntLevel2 + 1, 1)
If cntLevel1 > -1 Then id = id + Mid(slova, cntLevel1 + 1, 1)

ActiveCell.Offset(i, 4).Value = id + Mid(slova, rowCnt + 1, 1)
rowCnt = rowCnt + 1
If rowCnt >= 10 Then
cntLevel1 = cntLevel1 + 1
rowCnt = 0
If cntLevel1 >= 10 Then
cntLevel2 = cntLevel2 + 1
cntLevel1 = 0
End If
End If
Next i

and this what it displayed in my sheet.

 Bar Sum Waste 1 2460x1 1660x1 1060x1 660x1 5840 160 2 2460x1 1660x1 1060x1 660x1 5840 160 3 2460x1 1660x1 1060x1 660x1 5840 160 4 2460x1 1660x1 1060x1 660x1 5840 160 5 2460x2 660x1 5580 420 6 2460x2 660x1 5580 420 7 2460x2 660x1 5580 420 8 2460x2 660x1 5580 420 9 2460x2 660x1 5580 420 0 2460x2 660x1 5580 420 11 2460x2 660x1 5580 420 12 2460x2 660x1 5580 420 13 2460x2 4920 1080 14 2460x1 1660x1 4120 1880 15 1660x3 4980 1020 16 1660x3 4980 1020 17 2460x1 1660x2 5780 220 18 2460x1 1660x2 5780 220 19 1260x3 1060x2 5900 100 10 1260x3 1060x2 5900 100 21 1260x3 1060x2 5900 100 22 1260x3 1060x2 5900 100

<colgroup><col><col><col span="2"><col><col span="2"></colgroup><tbody>
</tbody>

you will notice that the number in the Bars are not corresponding accordingly. 0 and 10.
cant figure it out.

#### Mabangiz32

##### New Member
basically, the problem is the sequence of the numbers which i cannot figure it out.
Bar
1
2
3
4
5
6
7
8
9
10
11
and so forth...

Replies
3
Views
34
Replies
1
Views
64
Replies
1
Views
232
Replies
3
Views
209
Replies
2
Views
65

1,109,335
Messages
5,528,096
Members
409,802
Latest member
joeino

### This Week's Hot Topics

• Change military grades into rank
Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
• VBA COUNTIF SOLUTION
Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
• INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...