2017-08-30 109 views
1

我有我從信用卡帳單修復粘貼的文本

樣品1號線複製這個文本文件:

August 18  August 18  Balance Conversion  :02/06   4,671.30 

樣品線2:

August 1  August 2  *Php-Anytiefit-Ezypay Kuala Lumpur 2,300.00 

我將其從PDF文件複製到MS Excel文件中。我會得到下面的文本雙空格,每行只是粘貼到一個單元格,如下所示。

我嘗試使用文本函數=RIGHT(B73,LEN(B73)-E73+2)和陣列=MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},B73&""))等。我從研究中得到的數組,但我仍然會調整公式,因爲月份字符數字每個月都在變化,而且還是單位或雙位數日。

使用逗號和點分隔符,金額恆定爲小數點後兩位。除非有安裝線,例如01/24,這個「二十四」之一將會出現在數額2,916.25之前,如0 1/2 4 2 , 9 1 6 . 2 5

我正在尋找使用VBA解決方案或函數來修復粘貼的值。

A u g u s t 1 8 A u g u s t 1 8 P o w e r M a c C e n t e r r G b 3:0 1/2 4 2,9 1 6。 2 5
A u g u s t 1 8 A u g u s t 1 8 B a l c n n e c o n v e r s i o n:0 2/0 6 4,6 7 1。 3 0
A u g u s t 1 A u g u s t 2 * P h p - A n y t i m e f i t - E z y p a y K u a l a L u p u r r 2,3 0 0。 0 0
A u g u s t 1 3 A u g u s t 1 5 S t a r b u c k s C o n s e s s s Q c 2 7 5。 0 0

+0

對於這樣的問題導入PDF文件的內容到Excel中一些測試代碼,考慮粘貼到Word和使用高級查找/替換。如果需要,通配符搜索可能非常強大。這裏有一個網站描述這些:http://wordmvp.com/FAQs/General/UsingWildcards.htm –

回答

0

這是通過運行它通過MSWORD

Sub pdf2excel() 

    ' import pdf file text into excel, using msWord as a proxy 

    ' set reference to microsoft word object library 

    Dim wdApp As Word.Application 
    Set wdApp = New Word.Application 

    Dim file As String 
    file = "C:\statements\statement.pdf" 

    Dim wdDoc As Word.Document 
    Set wdDoc = wdApp.Documents.Open(_ 
        Filename:=file, ConfirmConversions:=False, _ 
        ReadOnly:=True, AddToRecentFiles:=False, _ 
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ 
        WritePasswordDocument:="", WritePasswordTemplate:="", _ 
        Format:=wdOpenFormatAuto, XMLTransform:="") 

' wdApp.Visible = false     ' can make msWord visible if you want ... would help in determining location of data 

    Dim cel As Range 
    Set cel = Range("d2")     ' put paragraph text in column D 

    Dim prgf As Paragraph 
    For Each prgf In wdDoc.Paragraphs 
     cel = prgf.Range.Text    ' put paragraph into worksheet cell 
     Set cel = cel.offset(1)    ' point to next cell down 
    Next prgf 

    Set cel = Range("b2")     ' put word text in column D 

    Dim wrd As Word.Range 
    For Each wrd In wdDoc.Words 
     cel = wrd.Text 
     Set cel = cel.offset(1) 
    Next wrd 

    wdDoc.Close False 
    Set wdDoc = Nothing 

    wdApp.Quit 
    Set wdApp = Nothing 

End Sub 
+0

我沒有運行代碼,更改路徑並啓用項目引用庫中的Microsoft Word和PDF。儘管我得到了'運行時1004'錯誤。我加入了代碼,它只是反覆運行在For-Next上。 –

+0

確保你有一個空白的工作表。它應該將值放入單元格 – jsotola

+0

有沒有可以修復MS Excel中粘貼值的解決方案? –