Results 1 to 2 of 2

VBA Code Help needed to move Account Number rows to different shet

Threaded View

  1. #1
    Registered User
    Join Date
    04-15-2014
    Location
    ohio
    MS-Off Ver
    Excel 2003
    Posts
    3

    VBA Code Help needed to move Account Number rows to different shet

    I been surfing the web and trying to figure out a formula to solve a work issue i'm having. I have a spreadsheet everymonth that contains about 10,000 lines in it. I would like to get a VBA together to help make the sorting process easier. I want it to sort by Column B which contains the account number, but i want it to only sort by the first 6 digits of the account number. Example :In Column B, 030-445-4955-49449-000 , but i would like the sorting to be done by 030-445. The first six digits represent a department within my company and the last digits are their expense line. I found this code on-line, but it takes all the different account number in B and sorts them. Can anyone help me tune this code to me needs? Thank you in advance.
    Sub parse_data()
    Dim lr As Long
    Dim ws As Worksheet
    Dim vcol, i As Integer
    Dim icol As Long
    Dim myarr As Variant
    Dim title As String
    Dim titlerow As Integer
    vcol = 2
    Set ws = Sheets("Sheet1")
    lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
    title = "A1:C1"
    titlerow = ws.Range(title).Cells(1).Row
    icol = ws.Columns.Count
    ws.Cells(1, icol) = "Unique"
    For i = 2 To lr
    On Error Resume Next
    If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
    ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
    End If
    Next
    myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
    ws.Columns(icol).Clear
    For i = 2 To UBound(myarr)
    ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
    If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
    Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
    Else
    Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
    End If
    ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
    Sheets(myarr(i) & "").Columns.AutoFit
    Next
    ws.AutoFilterMode = False
    ws.Activate
    End Sub
    Last edited by hollywoodbob; 04-16-2014 at 12:42 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Code needed to move rows to different worksheet based on date
    By collinlo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2012, 11:28 AM
  2. Replies: 1
    Last Post: 09-07-2012, 12:00 PM
  3. [SOLVED] need Macro code for validation of account number
    By tmprao27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2012, 06:30 AM
  4. Summing Rows based on Account Number
    By chalaki in forum Excel General
    Replies: 1
    Last Post: 06-21-2011, 02:12 PM
  5. Shet Number Position
    By Sheets number position in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2005, 08:05 AM

Tags for this Thread

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