help in macro_newbie

Mabangiz32

New Member
Joined
Mar 28, 2018
Messages
4
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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.



[TABLE="width: 423"]
<colgroup><col><col><col span="2"><col><col span="2"></colgroup><tbody>[TR]
[TD]Bar[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Sum[/TD]
[TD]Waste[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2460x1[/TD]
[TD]1660x1[/TD]
[TD]1060x1[/TD]
[TD]660x1[/TD]
[TD]5840[/TD]
[TD]160[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2460x1[/TD]
[TD]1660x1[/TD]
[TD]1060x1[/TD]
[TD]660x1[/TD]
[TD]5840[/TD]
[TD]160[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]2460x1[/TD]
[TD]1660x1[/TD]
[TD]1060x1[/TD]
[TD]660x1[/TD]
[TD]5840[/TD]
[TD]160[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]2460x1[/TD]
[TD]1660x1[/TD]
[TD]1060x1[/TD]
[TD]660x1[/TD]
[TD]5840[/TD]
[TD]160[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD][/TD]
[TD][/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]2460x2[/TD]
[TD]660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5580[/TD]
[TD]420[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]2460x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]4920[/TD]
[TD]1080[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]2460x1[/TD]
[TD]1660x1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]4120[/TD]
[TD]1880[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]1660x3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]4980[/TD]
[TD]1020[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]1660x3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]4980[/TD]
[TD]1020[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]2460x1[/TD]
[TD]1660x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5780[/TD]
[TD]220[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]2460x1[/TD]
[TD]1660x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5780[/TD]
[TD]220[/TD]
[/TR]
[TR]
[TD]19[/TD]
[TD]1260x3[/TD]
[TD]1060x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5900[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]1260x3[/TD]
[TD]1060x2[/TD]
[TD][/TD]
[TD][/TD]
[TD]5900[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]21[/TD]
[TD]1260x3[/TD]
[TD]1060x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5900[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]22[/TD]
[TD]1260x3[/TD]
[TD]1060x2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5900[/TD]
[TD]100[/TD]
[/TR]
</tbody>[/TABLE]



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

thank you for your patience..
 
Upvote 0
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...
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top