Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Ayden Smith   on Feb 20 In MS Office Category.

  
Question Answered By: Code Guru   on Feb 20

OK, I think I have the basic logic for the Acct number  issue!!
See if this helps....

Sub TestAcctNumberCell()
vCellAddress = Application.ActiveCell.Address
vAcctOriginal = Range(vCellAddress).Value
vAcctNew = vAcctOriginal
vLength = Len(vAcctOriginal)

For vChar = 1 To vLength
vCharPosition = Mid(vAcctNew, vChar, 1)
Select Case vCharPosition
Case "."
'leave Char position alone!
Case 0 To 9
'leave Char position alone!
Case Else
'replace any non numeric value with a 'blank'
Mid(vAcctNew, vChar, 1) = " "
End Select
Next vChar

Range(vCellAddress).Offset(0, 3).Value = vAcctOriginal

SplitAcct = Split(vAcctNew, ".")
For i = 0 To UBound(SplitAcct)
Range(vCellAddress).Offset(0, 4 + i).Value = SplitAcct(i)
Next i
End Sub

Copy some example AcctNumbers with mixed text, periods & numbers.
Then click to select an AcctNumber to test  with the Code above.
The results will be written 3 cells to the right of the selected cell.
The 3rd cell shows the original AcctNumber.
The 4th cell will show the prefix or 'left' side of a decimal AcctNumber.
The 5th cell will show the suffix or 'right' side of a decimal AcctNumber.

If this solves your case, this can be set up to run against the whole AcctNumber
& Amount data columns by loading the data into array structures (very fast!).

Anyway, see if this fits the bill.

Share: 

 

This Question has 20 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on trouble with IF/OR, Left and a simple loop Or get search suggestion and latest updates.


Tagged: