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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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.



Bar SumWaste
12460x11660x11060x1660x15840160
22460x11660x11060x1660x15840160
32460x11660x11060x1660x15840160
42460x11660x11060x1660x15840160
52460x2660x1 5580420
62460x2660x1 5580420
72460x2660x1 5580420
82460x2660x1 5580420
92460x2660x1 5580420
02460x2660x15580420
112460x2660x1 5580420
122460x2660x1 5580420
132460x2 49201080
142460x11660x1 41201880
151660x3 49801020
161660x3 49801020
172460x11660x2 5780220
182460x11660x2 5780220
191260x31060x2 5900100
101260x31060x25900100
211260x31060x2 5900100
221260x31060x2 5900100

<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.

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,214,531
Messages
6,120,073
Members
448,943
Latest member
sharmarick

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