Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Joseph,
You already got many good suggestions on how to solve your task. If you like your original code corrected: Sub manhours_cal_corr() 'declaration Dim resource As String Dim trade As String Dim labour As String Dim labour1 As String Dim cell As Object Dim total As Integer Dim count As Integer Dim num As Integer Sheets("Data").Select Range("E2:E1000").Select Selection.SpecialCells(xlCellTypeConstants, 23).Select For Each cell In Selection resource = cell.Value If resource = "" Then total = 0 Else For count = 1 To 10 num = InStr(1, resource, ",") trade = Left(resource, num) If num = 0 Then count = 11 trade = resource End If 'MsgBox ("Resource: " & resource) resource = Right(resource, Len(resource) - num) num = InStr(1, trade, "[") 'MsgBox (num) If num < 1 Then labour1 = 100 Else 'MsgBox (trade) labour = Right(trade, Len(trade) - num) 'MsgBox ("Labour: " & labour) If labour < "" Then labour1 = Left(labour, InStr(1, labour & "%", "%") - 1) 'MsgBox ("Labour1: " & labour1) End If End If total = total + (labour1 / 100) 'MsgBox ("Total: " & total) Next count End If cell.Value = total total = 0 Next cell End Sub Regards, Bernd |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
String Manipulation within VBA | Excel Discussion (Misc queries) | |||
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) | Excel Programming | |||
Importing Long String - String Manipulation (EDI EANCOM 96a) | Excel Programming | |||
string manipulation | Excel Programming | |||
VBA String manipulation | Excel Programming |