So the scenario I have is there are letter with a number:
Desired Output after Program (Note an underscore is visually used but I need a space:
____________F
__G
_____E
__G__E______F
Currently I have written code in the Number and First Letter Column to extract the number and first letter:
First Letter:
LEFT(A2,1)
Number:
=SUMPRODUCT(MID(0&A2,LARGE(INDEX(ISNUMBER(--MID(A2,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)
Now my VBA Script can take the number and character to get the information and output for (For ONE Error Code):
Private Sub Code_Printer_Click()
Dim myFile As String, rng As Range, cellValue As Variant, I As Integer, j As Integer
myFile = "C:\Reformatted.txt"
Set rng = Selection
Open myFile For Output As #1
For I = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
If j = rng.Columns.Count Then
cellValue = Space(rng.Cells(I, 1)) + CStr(rng.Cells(I, 2).Value)
Print #1, cellValue
End If
Next j
cellValue = ""
Next I
Close #1
Shell "C:\Windows\Notepad.exe C:\Reformatted.txt", 1
End Sub
RESULT:
So please help me process multiple codes in the same event.
If an excel function needs to be done thats fine. If its easier to extract the number in VBA thats ok to. Non technical people will use so the more VBA the better. Please let me know if this is a slow or if there is a faster, easier way to do this! :)
-----------------------------Final Data---------------------------------------
This is how I'd do it -
So it searches for the first parentheses
(
and tackles the character and spaces. Then it looks for another(
- if it finds one, it continues, otherwise it's done (and prints).If it continues, it finds the next
(
and does the same test finding the character and spaces, then checks the string to see if the length of the string is greater than the number of spaces. If it is, it replaces a blank character with your character. If not, it appends spaces and then inserts the character at the end.Then it searches again for a
(
to repeat the process.Right now it is searching column A and printing in column B - adjust as needed. You can print
mystring
to file.