Solved

Excel VBA Text to Columns

Posted on 2014-04-07
2
480 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

615 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