Results 1 to 3 of 3

Need help fixing VBA script.. This site has been a Great help..Thanks to all...

Threaded View

  1. #1
    Registered User
    Join Date
    06-30-2010
    Location
    Newport New VA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Need help fixing VBA script.. This site has been a Great help..Thanks to all...

    Judgeh59 you helped me create this, and it works well.. Thanks.. except i forgot one little detail
    That causes it to pull wrong data..

    I need for it to pull only the data adjacent to the 0 in Row A.. So if there is a 0 then run this script.. Yes Still need to pull the
    header data.. but the rest of the data has to start at the point where there is a 0 in row A..right now it starts at the very top.

    If you look at the spreadsheet I attached.. the fields colored in blue and have a 1 next to them in column A should not be pulled.
    here is the current code

    Sub CreatTab()
    
        Dim Names()
        Dim x As Integer
        Dim LastRow As Single, TempLastRow As Single, y As Single
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
    
        Names = Array("VA", "100", "IL", "200", "CA", "300", "NJ", "400", "PR", "500", "TX", "600", "Warranty", "900")
    
        For x = 0 To UBound(Names) Step 2
            Range("b2:Y2").Select
            Selection.Copy
            Sheets.Add After:=Sheets(Sheets.Count)
            ActiveSheet.Name = Names(x)
            Range("b2").Select
            ActiveSheet.Paste
            Sheets("Sheet1").Activate
        Next x
    
        LastRow = Cells(65000, 1).End(xlUp).Row
    
        For x = 0 To UBound(Names) Step 2
            For y = 3 To LastRow
                If Left(Cells(y, 2).Value, 3) = Names(x + 1) And Cells(y, 1).Value = 0 Then
                    TempLastRow = Sheets(Names(x)).Cells(65000, 2).End(xlUp).Row
                    Range("B" & y & ":" & "Y" & y).Select
                    Selection.Copy
                    Sheets(Names(x)).Activate
                    Cells(TempLastRow + 1, 2).Select
                    ActiveCell.PasteSpecial
                    Sheets("Sheet1").Activate
                End If
            Next y
        Next x
    
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
    
    End Sub
    File attached..
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Found A Great VBA Script To Hide Formulas Without Protect Sheet But Still Buggy..
    By resshin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2013, 11:11 AM
  2. [SOLVED] need help fixing vlookup script and adding second step
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-23-2013, 06:51 AM
  3. Hello everyone, great site.
    By XxCMoneyxX in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 11-30-2012, 07:22 PM
  4. Great Site and Thanks For the Help
    By Excellerator in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2006, 04:42 AM
  5. [SOLVED] THIS IS A GREAT SITE! THANK YOU!!!!
    By Excel User in forum Excel General
    Replies: 1
    Last Post: 08-08-2005, 02:07 PM

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