Morten Lahrmann
New Member
- Joined
- Jan 25, 2011
- Messages
- 3
Hey all
Im working on a sheet to keep track of a procentage of defects at my job. Here I've created a Submit-button which move three pieces of information "Batchnumber, Precentage, and Product" to another sheet in the same workbook. However, we have two categories of products and I would like to for the submit-macro to place the information moved differently depending on the category.
I would thinking some sort of IF-statement along the lines of "IF the product is PX1, PX2, PX3 move to "B", "C", "D" ELSE move to "F", "G", "H"", but dont know exactly how to include it in the macro code below.
Anyone have any experiences with something similar?
BR
Morten, Denmark
Im working on a sheet to keep track of a procentage of defects at my job. Here I've created a Submit-button which move three pieces of information "Batchnumber, Precentage, and Product" to another sheet in the same workbook. However, we have two categories of products and I would like to for the submit-macro to place the information moved differently depending on the category.
I would thinking some sort of IF-statement along the lines of "IF the product is PX1, PX2, PX3 move to "B", "C", "D" ELSE move to "F", "G", "H"", but dont know exactly how to include it in the macro code below.
Anyone have any experiences with something similar?
BR
Morten, Denmark
Code:
Sub Rectangle2_Click()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim r1 As Range, r2 As Range
Dim v1 As Variant, v2 As Variant
Set sh1 = Worksheets("Fyldefejl")
Set sh2 = Worksheets("Data")
v1 = Array("E27", "F27", "G27")
v2 = Array("B", "C", "D")
rw = sh2.Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).Row
For i = LBound(v1) To UBound(v1)
Set r1 = sh1.Range(v1(i))
Set r2 = sh2.Cells(rw, v2(i))
r1.Copy r2
r1.ClearContents
Next i
End Sub