Results 1 to 12 of 12

Having trouble with macro coping data to sheet2

Threaded View

  1. #1
    Registered User
    Join Date
    12-03-2013
    Location
    Clearwater, FL
    MS-Off Ver
    Excel 2013
    Posts
    10

    Having trouble with macro coping data to sheet2

    I have a macro for a button that isnt fully working. what it does it looks at data on sheet1 for data in columns I-L all the way down and it there is data in Column I it copies I-L row over to sheet2 and puts info in same order in sheet2 A-D and then looks at values in column D on sheet2 and whatever number is there makes that many copies (-1) under it and does this for all. So another words if column D on sheet2 says 12 it makes 12 - 1 copies and puts it right under that row so theres a total ** 12 ** those rows. which this works perfect what isnt working fully is on sheet1 theres some rows with data in Column I that it doesnt see or something so it doesnt copy that row (I-L) over and some rows it does .... cant figure it out heres my code.

    It also auto widths both sheets.

    Sub copyData()
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        Sheets("Sheet1").Columns("A:L").WrapText = False
        Sheets("Sheet1").Columns("A:L").Aut**it
    
        Dim rowCounter As Integer
        Dim insertNumber As Integer
        Dim insertCount As Integer
        Dim countBlank As Integer
        Dim rowCounter1 As Integer
        
        countBlank = 0 '''used to know when you reach the end ** your data
        rowCounter = 3 ''where your data starts
        numberRows = 0
        rowCounter1 = 1
        
        Sheets("Sheet2").Cells.Clear
        '''''puts appropriate number ** each item on sheet
        Do Until countBlank = 10
            If Sheets("Sheet1").Cells(rowCounter, 9).Value <> Empty Then
                countBlank = 0
                numberRows = Sheets("Sheet1").Cells(rowCounter, 12).Value
                For numberCount = 1 To numberRows Step 1
                    Sheets("Sheet2").Cells(rowCounter1, 1).Value = Sheets("Sheet1").Cells(rowCounter, 9).Value
                    Sheets("Sheet2").Cells(rowCounter1, 2).Value = Sheets("Sheet1").Cells(rowCounter, 10).Value
                    Sheets("Sheet2").Cells(rowCounter1, 3).Value = Sheets("Sheet1").Cells(rowCounter, 11).Value
                    Sheets("Sheet2").Cells(rowCounter1, 4).Value = Sheets("Sheet1").Cells(rowCounter, 12).Value
                    rowCounter1 = rowCounter1 + 1
                Next
                rowCounter = rowCounter + numberRows
            Else
                countBlank = countBlank + 1
            End If
            rowCounter = rowCounter + 1
        Loop
    
        Sheets("Sheet2").Columns("A:D").WrapText = False
        Sheets("Sheet2").Columns("A:D").Aut**it
        Sheets("Sheet2").Select
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        
    End Sub
    Last edited by Asphalt_Cowboy; 03-08-2014 at 08:04 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Does xl2011 fully support VBA?
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-28-2010, 11:54 AM
  2. Failure to fully open
    By thonikman in forum Excel General
    Replies: 1
    Last Post: 11-24-2008, 09:43 AM
  3. Excel won't open fully
    By mpeplow in forum Excel General
    Replies: 1
    Last Post: 06-09-2007, 11:33 AM
  4. Fully functional spreadsheets on web?
    By famdamly in forum Excel General
    Replies: 4
    Last Post: 04-18-2006, 05:21 AM
  5. xl environment not fully functional
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2005, 05:05 PM

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