Hi all,
Here is my code. Maybe i could run it off 1 button (click event??)
Any ideas to shorten it???
thank you!!
Private Sub CommandButton1_Click()
CopyData Range("D9

13"), "FEEDER"
CopyData Range("D16

58"), "MACHINE"
CopyData Range("D63

73"), "DELIVERY"
CopyData Range("D78

82"), "PECOM"
CopyData Range("D88

94"), "ROLLERS"
CopyData Range("D104

128"), "MISCELLANEOUS"
End Sub
Private Sub CopyData(rngD As Range, Target As String)
Dim rng As Range, cell As Range
Dim rng1 As Range, rng2 As Range
Dim rng3 As Range
Dim nrow As Long, rw As Long
Dim Sh As Worksheet
nrow = Application.CountIf(rngD, ">0")
If nrow = 0 Then Exit Sub
Set Sh = Worksheets("Quote2")
Set rng = Sh.Columns(1).Find(What:=Target, _
After:=Sh.Range("A1"), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Set rng3 = rng
Worksheets("quote2").Unprotect Password:="jenjen1"
rng.Offset(1, 0).ClearContents
If Application.CountA(rng3) > 2 Then
Else
Set rng3 = rng.Offset(2, 0)
End If
rw = rng3.Row
rng3.Resize(nrow * 2, 1).EntireRow.Insert
For Each cell In rngD
If Not IsEmpty(cell) Then
If IsNumeric(cell) Then
If cell > 0 Then
Cells(cell.Row, 1).Resize(1, 2).Copy _
Destination:=Sh.Cells(rw, 1)
rw = rw + 2
End If
End If
End If
Next
Worksheets("quote2").Protect Password:="jenjen1"
End Sub
Private Sub Commandbutton2_click()
CopyData Range("E9:E128"), "OPTIONS"
End Sub
Private Sub CopyData2(rngE As Range, Target As String)
Dim rng As Range, cell As Range
Dim rng1 As Range, rng2 As Range
Dim rng3 As Range
Dim nrow As Long, rw As Long
Dim Sh As Worksheet
nrow = Application.CountIf(rngE, ">0")
If nrow = 0 Then Exit Sub
Set Sh = Worksheets("Quote2")
Set rng = Sh.Columns(1).Find(What:=Target, _
After:=Sh.Range("A1"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Set rng3 = rng
Worksheets("quote2").Unprotect Password:="jenjen1"
rng.Offset(2, 0).ClearContents
If Application.CountA(rng3) > 2 Then
Else
Set rng3 = rng.Offset(2, 0)
End If
rw = rng3.Row
rng3.Resize(nrow * 2, 0).EntireRow.Insert
For Each cell In rngE
If Not IsEmpty(cell) Then
If IsNumeric(cell) Then
If cell > 0 Then
Cells(cell.Row, 1).Range("A9,B9").Copy _
Destination:=Sh.Cells(rw, 3)
rw = rw + 2
End If
End If
End If
Next
Worksheets("quote2").Protect Password:="jenjen1"
End Sub
Private Sub CommandButton3_Click()
CopyData Range("D9

13"), "FEEDER"
CopyData Range("D16

58"), "MACHINE"
CopyData Range("D63

73"), "DELIVERY"
CopyData Range("D78

82"), "PECOM"
CopyData Range("D88

94"), "ROLLERS"
CopyData Range("D104

128"), "MISCELLANEOUS"
Dim rng As Range, cell As Range
Dim nrow As Long, rw As Long
Dim col As String
Dim Sh As Worksheet
Set rng = Range("D9

94")
nrow = Application.CountIf(rng, ">0")
Set Sh = Worksheets("VK new")
rw = 10
For Each cell In Range("D9

98")
If Cells(cell.Row, "D").Interior.ColorIndex = 3 Then
col = "G"
Else
col = "F"
End If
If Not IsEmpty(cell) Then
If IsNumeric(cell) Then
If cell > 0 Then
Cells(cell.Row, 1).Copy
Sh.Cells(rw, "A").PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 4).Copy
Sh.Cells(rw, col).PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 2).Copy
Sh.Cells(rw, "B").PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 3).Copy
Sh.Cells(rw, "E").PasteSpecial Paste:=xlPasteValues
rw = rw + 1
End If
End If
End If
Next
For Each cell In Range("E9:E98")
If Not IsEmpty(cell) Then
If IsNumeric(cell) Then
If cell > 0 Then
Cells(cell.Row, 1).Copy
Sh.Cells(rw, "A").PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 5).Copy
Sh.Cells(rw, "G").PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 2).Copy
Sh.Cells(rw, "B").PasteSpecial Paste:=xlPasteValues
Cells(cell.Row, 3).Copy
Sh.Cells(rw, "E").PasteSpecial Paste:=xlPasteValues
rw = rw + 1
End If
End If
End If
Next
End Sub