+ Reply to Thread
Results 1 to 2 of 2

Sub for performing a function across multiple worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    Perth, WA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Sub for performing a function across multiple worksheets

    The sub below executes a Text to Columns function on the active sheet (eg January) but how would I get this to perform the same function simultaneously across three or more specified worksheets eg January but also the February and March worksheets?


       
    Sub Calc_WS() Columns("G:G").Select
        Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(1, 1), TrailingMinusNumbers:=True
    End Sub
    Thanks

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sub for performing a function across multiple worksheets

    Something along the lines of the below perhaps ?

    Dim vWS As Variant, bWS As Byte
    vWS = Array("January","February","March")
    For bWS = LBound(vWS) To UBound(vWS) Step 1
        With Sheets(vWS(bWS)).Columns("G")
            .TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, Tab:=True, FieldInfo:=Array(1, 1)
        End With
    Next bWS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1