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
Bookmarks