Advertisement
Advertisement
| 10.07.2008 at 11:16AM PDT, ID: 23794720 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: |
Sub MakeFixedWidth()
Dim Sizes As Variant
Dim arr As Variant
Dim FieldFormats As Variant
Dim r As Long, c As Long
Dim fso As Object
Dim ts As Object
Dim TheLine As String
Dim TestStr As String
Sizes = Array(20, 16, 12, 12, 8, 1, 1, 8, 8, 8, 21, 21, 21, 21, 21, 21, 4, 16, 1, 16, 1, 16, 1, 16, 1, 12, 8)
arr = ActiveSheet.UsedRange
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile("I:\MPT\TradeFile\MPOWERTRA.txt", True)
For r = 1 To UBound(arr, 1)
TheLine = ""
For c = 1 To UBound(arr, 2)
TestStr = Trim(CStr(arr(r, c))) 'assign value of cell to TestStr and remove all leading and trailing spaces
'Make choices here depending on which field is being processed
Select Case c
Case 1 To 10
TestStr = Left(Trim(CStr(arr(r, c))), Sizes(c - 1))
TheLine = TheLine & TestStr & String(Sizes(c - 1) - Len(TestStr), " ")
Case 11 To 15 'format cell, Remove decimals, then add zeros
TestStr = Replace(TestStr, ".", "") 'Remove decimals
TheLine = TheLine & String(Sizes(c - 1) - Len(TestStr), "0") & TestStr
Case 18, 20, 22, 24 ' Just add zeros
TestStr = Left(Trim(CStr(arr(r, c))), Sizes(c - 1))
TheLine = TheLine & TestStr & String(Sizes(c - 1) - Len(TestStr), "0") 'add zeros
Case Else ' all other cases simply extract but do not change anything (except for the leading and trailing spaces that have already been removed)
'do nothing...leave field like it is
TheLine = TheLine & TestStr & String(Sizes(c - 1) - Len(TestStr), " ")
End Select
Next c
ts.WriteLine TheLine
Next r
ts.Close
Set ts = Nothing
Set fso = Nothing
MsgBox "Done"
End Sub
|