VBA excel on date form Inventor... Vlookup keep fail.. Why?

VBA excel on date form Inventor... Vlookup keep fail.. Why?

Darkforce_the_ilogic_guy
Advisor Advisor
183 Views
0 Replies
Message 1 of 1

VBA excel on date form Inventor... Vlookup keep fail.. Why?

Darkforce_the_ilogic_guy
Advisor
Advisor

I have this code in Excel VBA 

Dim rownr
Dim TotalUnit As Integer
Dim Total As Integer
Dim countup As Integer

rownr = 2
 Do Until Cells(rownr, 36).Value = ""
 TotalUnit = 0
 Total = 0
 
 'main item for this count
 
 TotalUnit = (Len(Cells(rownr, 36)) - 1)

 Total = Cells(rownr, 37)

 Cells(rownr, 38).Value = Total
 ' add secondar unit
 currentItem = 1

  Do Until TotalUnit = 0
  
   
  If Right(left((Cells(rownr, 36).Value), (TotalUnit + 1)), 1) = "." Then
  
    Multiunit = 0
  
    Multiunit = Application.WorksheetFunction.VLookup(left(Cells(rownr, 36).Value, TotalUnit), Range("A:AL"), 37, False)

 If Multiunit = 0 Then
  Multiunit = 1
 End If
    Total = Total * Multiunit

  Else

  End If '
 TotalUnit = TotalUnit - 1

  Loop
 Cells(rownr, 38).Value = Total

  rownr = rownr + 1
 Loop
End Sub

 The Code give me this 

 

bt_0-1669359236560.png

 

But I was surpose to get this

 

bt_1-1669359316421.png

 it seems that the Vloopup fail for some reason ... the thing is that the same code have work in a Test excel.. back then it seems that it wanted to have AJ as String in formating in excel and AK as number to work ... one other problem it have that the code need to be under the Sheet... and not the workbook folder ... I have done both as far as I know is the final doc.. that I try to creat.. .. but it seems to not work no matter what I do.  Any idear why and how to fix it?

 

0 Likes
184 Views
0 Replies
Replies (0)