Cut off digits

  • Thread starter samotek via AccessMonster.com
  • Start date
S

samotek via AccessMonster.com

I have a table called table2 and texts in the field "grade".Is it possible
through a code to cut the last digits from the row and paste them in the
other field called "price"? For for example in the row
Pento Super Performance III 5W-30 12 x 1 L 3,74
Pento Super Performance III 5W-30 3 x 5 L 17,60

to cut the digit 3,74 or 17,60 and paste them in the field price.And after
that to delete the letter L
 
J

John... Visio MVP

samotek via AccessMonster.com said:
I have a table called table2 and texts in the field "grade".Is it possible
through a code to cut the last digits from the row and paste them in the
other field called "price"? For for example in the row
Pento Super Performance III 5W-30 12 x 1 L 3,74
Pento Super Performance III 5W-30 3 x 5 L 17,60

to cut the digit 3,74 or 17,60 and paste them in the field price.And after
that to delete the letter L


You can do that through VBA. The following code will put the last bit of the
string in a seperate variable. The code searches for <blank>L<blank>. Since
there is no guarantee that there are no other occurrences of that string,
the search starts from the end (InStrRev)

Sub Macro3()

Dim TmpStr As String
Dim NewStr As String
Dim i As Integer

TmpStr = "Pento Super Performance III 5W-30 12 x 1 L 3,74"

i = InStrRev(TmpStr, " L ")
NewStr = IIf(i > 0, Right(TmpStr, Len(TmpStr) - i - 2), "")

Debug.Print i
Debug.Print TmpStr
Debug.Print NewStr

End Sub

John... Visio MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top