TimCor
10-25-2012, 08:50 AM
Good day all
Outlook 2007
I am a real beginner at VBA but have managed to get almost everything from web sources. I have standard incoming emails which I select and a macro that transfers everything to an Excel spreadsheet, and loads them under column letters. My email has one line with Product : Quantity : Price followed by the next line with the actual product, quantity and price. Each item is delineated by a colon. (The product description will vary in length)
How do I code my loop to look at these three items and transfer them to columns K L and M in my spreadsheet ??
SAMPLE OF INCOMING MESSAGE
For payment by :
' ==============Section that I need help with
Product : Quantity : Price
products here : 1 : 263.00
'========== to here
Voucher : -0.00
Continues from here OK
Example part of the VBA loop in use below.
If InStr(1, vText(i), "For payment by: ") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("G" & rCount) = Trim(vItem(1))
End If
'=============================================
'This is the section that needs looking at
If InStr(1, vText(i), "Product :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("H" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Quantity :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("I" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Price :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("J" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Product2 :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("K" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Quantity2:") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("L" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Price 2 :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("M" & rCount) = Trim(vItem(1))
End If
' =============================================
' All works from here onwards
If InStr(1, vText(i), "Voucher :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("O" & rCount) = Trim(vItem(1))
End If
Endlessly grateful for any assistance
TimCor
Outlook 2007
I am a real beginner at VBA but have managed to get almost everything from web sources. I have standard incoming emails which I select and a macro that transfers everything to an Excel spreadsheet, and loads them under column letters. My email has one line with Product : Quantity : Price followed by the next line with the actual product, quantity and price. Each item is delineated by a colon. (The product description will vary in length)
How do I code my loop to look at these three items and transfer them to columns K L and M in my spreadsheet ??
SAMPLE OF INCOMING MESSAGE
For payment by :
' ==============Section that I need help with
Product : Quantity : Price
products here : 1 : 263.00
'========== to here
Voucher : -0.00
Continues from here OK
Example part of the VBA loop in use below.
If InStr(1, vText(i), "For payment by: ") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("G" & rCount) = Trim(vItem(1))
End If
'=============================================
'This is the section that needs looking at
If InStr(1, vText(i), "Product :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("H" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Quantity :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("I" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Price :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("J" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Product2 :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("K" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Quantity2:") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("L" & rCount) = Trim(vItem(1))
End If
If InStr(1, vText(i), "Price 2 :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("M" & rCount) = Trim(vItem(1))
End If
' =============================================
' All works from here onwards
If InStr(1, vText(i), "Voucher :") > 0 Then
vItem = Split(vText(i), Chr(58))
xlSheet.Range("O" & rCount) = Trim(vItem(1))
End If
Endlessly grateful for any assistance
TimCor