Setting:
- Using VBA in Access
- Exporting four tables as four sheets in one new excel file with DoCmd.TransferSpreadsheet acExport
- modify the exported file withing vba code in access
What I want to do:
- There are four sheets in the excel file. In every sheet on all filled columns the "textToColumn" function should be applied.
The Problem:
- Making the first row bold works on every sheet. "textToColumn" functions only work on the first sheet.
My Code:
Dim xlApp As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlSheet = xlApp.Workbooks.Open("C:\Users\jfrick\Documents\BPM Access\Revenue Evolution GFS.xlsx")
With xlApp
.Application.Cells.Select
.Application.Selection.ClearFormats
.Application.Rows("1:1").Select
.Application.Selection.Font.Bold = True
.Application.Cells.Select
.Application.Selection.RowHeight = 12.75
.Application.Selection.Columns.AutoFit
.Application.Range("E:E").TextToColumns
.Application.Range("F:F").TextToColumns
.Application.ActiveWorkbook.Save
.Application.ActiveWorkbook.Close
.Quit
End With
I also tried using the following code snippet but this also only changes the columns in the first sheet:
Dim ws As Worksheet
For Each ws In xlApp.Worksheets 'also tried xlSheet.Worksheets but same result
ws.Application.Range("E:E").TextToColumns
ws.Application.Range("F:F").TextToColumns
Next ws
--> How can i apply the "textToColumn" function on the columns in every sheet?