Advertisement
Tony-S

excel to csv

Jan 21st, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Speichern mit ";" als Trennzeichen
  2. Sub SaveCSVSemicolon()
  3. Dim rngBereich As Range
  4. Dim rngZeile As Range
  5. Dim rngZelle As Range
  6. Dim strTemp As String
  7. Dim strPfad As String
  8.  
  9. strPfad = ThisWorkbook.Path + "\"
  10.  
  11. Const strDateiname As String = "csv_file"
  12. Const strErweiterung As String = ".csv"
  13. Const strTrennzeichen As String = ";"
  14.  
  15.    Set rngBereich = ActiveSheet.UsedRange 'Nur die gefüllten Zellen
  16.   Open strPfad & strDateiname & strErweiterung For Output As #1
  17.  
  18.    For Each rngZeile In rngBereich.Rows
  19.      For Each rngZelle In rngZeile.Cells
  20.        'Zellen, die ein "www" oder "http(s)" beinhalten in html a-Tags ändern
  21.       If ((InStr(1, rngZelle.Text, "www") > 0) Or (InStr(1, rngZelle.Text, "http") > 0)) Then
  22.          strTemp = strTemp & "<a href=""" & CStr(rngZelle.Text) & """>" & "Kartoffel" & "</a>;"""
  23.        Else
  24.          strTemp = strTemp & CStr(rngZelle.Text) & strTrennzeichen
  25.        End If
  26.        
  27.      Next
  28.      Print #1, strTemp
  29.    
  30.      strTemp = ""
  31.    Next
  32.    
  33.    Close #1
  34.    Set rngBereich = Nothing
  35. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement