Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / March 2008

Tip: Looking for answers? Try searching our database.

From word to Excel?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 22 Mar 2008 19:37 GMT
Hi

I am doing my taxes and need to find a way to convert my broker's 1099B
(stocks transactions during the year) from a text pdf form or Word
document into an excel format.  Is there a way to do this?

I can receive my 1099B data from my broker as a pdf or as a printed
statement.  But I need it in the form of a Excel spreadsheet with
multiple columns.  As a small example (the list is much longer which is
why I am asking), I put a representative sample copied and pasted from
the pdf into Word the same data copied and pasted from the pdf to an
Excel document.  They are at:
http://www.orthohelp.com/1099b.doc
http://www.orthohelp.com/1099b.xls

Is there a way to convert this into an excel spreadsheet format with
data columns that I can manipulate?

Thanks.

Jeff
Ron Rosenfeld - 22 Mar 2008 21:03 GMT
>Hi
>
[quoted text clipped - 17 lines]
>
>Jeff

Since you can get the data into the excel worksheet, a macro can parse it up
the way you would like.

Of course, you could use the Data/Text to columns wizard, but you'll have a
fair amount of cleanup to do after since you have an inconsistent "$", and also
no <space> between the end of the amount and the beginning of the company name
(and I presume some company names could start with a digit).

I have assumed that all amounts are reported to two decimal digits, as was the
case on the example you posted.

If your example is not representative, some changes may need to be made.

In any event, once you copy the data into your worksheet, run the F1099b Macro
and it should parse things out.

To enter the macro, <alt-F11> opens the VBEditor.  Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use this, first SELECT the cells that need to be Parsed.  Then,<alt-F8>
opens the macro dialog box.  Select F1099b and <RUN>.

=====================================
Option Explicit
Sub F1099b()
Dim rg As Range, c As Range
Dim Str As String, I As Long
Dim re As Object, mc As Object, m As Object
Set re = CreateObject("vbscript.regexp")
   re.Global = True
   re.Pattern = _
"^(\S+)\s(\S+)\s(\S+)\s(\S+)[\s$]+(\S+)[\s$]+([\d,]+\.\d\d)(.*$)"
'could setup rg in a variety of ways
Set rg = Selection
For Each c In rg
   Str = c.Value
If re.test(Str) = True Then
   Set mc = re.Execute(Str)
   For I = 1 To mc(0).submatches.Count
       Select Case I
           Case 1, 3
               c.Offset(0, I).NumberFormat = "@"
           Case 2
               c.Offset(0, I).NumberFormat = "mm/dd/yyyy"
           Case Else
               c.Offset(0, I).NumberFormat = "General"
       End Select
       c.Offset(0, I).Value = mc(0).submatches(I - 1)
   Next I
End If
Next c
End Sub
=========================
--ron
Jeff - 22 Mar 2008 21:36 GMT
>> Hi
>>
[quoted text clipped - 75 lines]
> =========================
> --ron

Dear Ron

Thank you so much for helping.

I tried it as described on the xls sample file I had posted above, but I
got a Microsoft Visual Basic error:
=========
Run-time error '432':
File name or class name not found during Automation operation
===========
Debug button took me to the following highlighted line (yellow):
Set re = CreateObject("vbscript.regexp")

For the record, I am using Excel 2002 with the latest Office updates.
It is possible I have the macros disabled from some past MS security
measure but am not sure.

Jeff
Ron Rosenfeld - 23 Mar 2008 02:09 GMT
>>> Hi
>>>
[quoted text clipped - 94 lines]
>
>Jeff

I don't understand why you got that error.  I've not read of that happening
before with createobject.  I would have thought that if you had macros
disabled, you would have seen some message  cluing you in.

In any event, try this:

1.  When in the VB Editor, from the main menu bar select Tools/References and
then select "Microsoft VBScript Regular Expressions 5.5" from the dropdown
list.

2.  Replace the code I gave you with the code below:

===================================================
Option Explicit
Sub F1099b()
'Requires reference to be set to
'Microsoft VBScript Regular Expressions 5.5
Dim rg As Range, c As Range
Dim Str As String, I As Long
Dim re As RegExp, mc As MatchCollection
Set re = New RegExp
   re.Global = True
   re.Pattern = _
"^(\S+)\s(\S+)\s(\S+)\s(\S+)[\s$]+(\S+)[\s$]+([\d,]+\.\d\d)(.*$)"
'could setup rg in a variety of ways
Set rg = Selection
For Each c In rg
   Str = c.Value
If re.test(Str) = True Then
   Set mc = re.Execute(Str)
   For I = 1 To mc(0).submatches.Count
       Select Case I
           Case 1, 3
               c.Offset(0, I).NumberFormat = "@"
           Case 2
               c.Offset(0, I).NumberFormat = "mm/dd/yyyy"
           Case Else
               c.Offset(0, I).NumberFormat = "General"
       End Select
       c.Offset(0, I).Value = mc(0).submatches(I - 1)
   Next I
End If
Next c
End Sub
=================================================
--ron
Jeff - 23 Mar 2008 11:52 GMT
>>>> Hi
>>>>
[quoted text clipped - 141 lines]
> =================================================
> --ron

Thank you again Ron.  Very kind of you.

Jeff
Ron Rosenfeld - 23 Mar 2008 12:34 GMT
>Thank you again Ron.  Very kind of you.
>
>Jeff

You're welcome.  I trust this latter method worked?  Glad to help.
--ron
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.