Solved

Excel VBA Text to Columns

Posted on 2014-04-07
2
470 Views
Last Modified: 2014-04-07
I need to format multiple Columns A,D,I,L Text to Columns on all worksheets except for 2 (Invoice and Summary).

Text to Column Parameters:
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
 Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
  :=Array(1, 1), TrailingMinusNumbers:=True
0
Comment
Question by:shieldsco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39983598
You can try this code, looping through the sheets and the columns:

Sub Macro1()
'
Dim shtLoop As Worksheet


For Each shtLoop In ActiveWorkbook.Worksheets

    If shtLoop.Name <> "Invoice" And shtLoop.Name <> "Summary" Then
           T2C shtLoop.[a1]
           T2C shtLoop.[D1]
           T2C shtLoop.[I1]
           T2C shtLoop.[L1]
    End If

Next shtLoop

End Sub

Private Sub T2C(rg As Range)

If Application.WorksheetFunction.CountA(rg.EntireColumn) Then _
    rg.EntireColumn.TextToColumns Destination:=rg, DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
     Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
      :=Array(1, 1), TrailingMinusNumbers:=True
End Sub

Open in new window


Thomas
0
 

Author Closing Comment

by:shieldsco
ID: 39983822
Works Good -- Thanks
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question