Results 1 to 10 of 10

Combine vba codes

Threaded View

mmwltd Combine vba codes 04-19-2010, 11:30 AM
JBeaucaire Re: Combine vba codes 04-19-2010, 01:04 PM
mmwltd Re: Combine vba codes 04-19-2010, 04:01 PM
JBeaucaire Re: Combine vba codes 04-20-2010, 12:07 AM
mmwltd Re: Combine vba codes 04-20-2010, 03:27 AM
JBeaucaire Re: Combine vba codes 04-20-2010, 11:07 AM
mmwltd Re: Combine vba codes 04-20-2010, 11:14 AM
mmwltd Re: Combine vba codes 04-21-2010, 04:01 AM
JBeaucaire Re: Combine vba codes 04-21-2010, 11:00 AM
mmwltd Re: Combine vba codes 04-22-2010, 08:32 AM
  1. #1
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Combine vba codes

    Hi
    I have large text files to convert and I would like to get all the codes combined into one, if thats possible.

    The text i want to parse has various quantity of 7 character partnumbers at the end. one piece of code splits the string out and the following formula can remove all the pieces split out from the original string so basically i have the fully original string and then the string split out into the individual parts.

    I cant find the vba for this formula but i have placed it below where it should run

    =LEFT(A1,SEARCH(B1,A1)-1)

    Can somebody take a look at that and maybe combine the formula and the following code into one piece?

    The code is in the order I'd like it performed - with the formula inserted where it should be.

    The one issue i found while testing the individual pieces is that most of them require the columns to be manually selected which i would prefer to happen automatically

    (I've found all this vba on the net)

    Thanks
    John


    
    Sub trimAnd Clean()
    
    Dim x As Long
    
    x = Range("B63556").End(xlUp).Row
    
    For i = 1 To x
    
        Cells(i, 2) = Application.Clean(Application.Trim(Cells(i, 2)))
    
    Next
    
     
    
    On Error Resume Next
    
    Columns(2).Replace What:=Chr(160), Replacement:="", LookAt:=xlPart
    
    End Sub


    
     Sub ParseFromRight()
    
    Dim LR As Long, i As Long, x As Long, Counter As Long, ValArray As Variant
    
    LR = Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = 2 To LR
    
        Counter = 0
    
        With Cells(i, "A")
    
            ValArray = Split(.Value, " ")
    
            For x = UBound(ValArray) To LBound(ValArray) Step -1
    
                If Len(ValArray(x)) <> 7 Then Exit For
    
                Counter = Counter + 1
    
                .Offset(0, Counter).Value = ValArray(x)
    
            Next x
    
        End With
    
    Next i
    
    End Sub




    
     =LEFT(A1,SEARCH(B1,A1)-1)


    
    Sub FlipColumns()
    
        Dim vTop As Variant
    
        Dim vEnd As Variant
    
        Dim iStart As Integer
    
        Dim iEnd As Integer
    
            Application.ScreenUpdating = False
    
            iStart = 1
    
            iEnd = Selection.Columns.Count
    
            Do While iStart < iEnd
    
                vTop = Selection.Columns(iStart)
    
                vEnd = Selection.Columns(iEnd)
    
                Selection.Columns(iEnd) = vTop
    
                Selection.Columns(iStart) = vEnd
    
                iStart = iStart + 1
    
                iEnd = iEnd - 1
    
            Loop
    
            Application.ScreenUpdating = True
    
    End Sub


    
    Sub DelEmptyMoveLeft()
    
        Cells.Select
    
        Selection.SpecialCells(xlCellTypeBlanks).Select
    
        Selection.Delete Shift:=xlToLeft
    
    End Sub
    Last edited by mmwltd; 04-22-2010 at 08:36 AM.

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