Excel macro copying cells based on criteria
Closed
nsy2204
Posts
2
Registration date
Friday November 6, 2009
Status
Member
Last seen
November 6, 2009
-
Nov 6, 2009 at 08:43 PM
nsy2204 Posts 2 Registration date Friday November 6, 2009 Status Member Last seen November 6, 2009 - Nov 6, 2009 at 11:23 PM
nsy2204 Posts 2 Registration date Friday November 6, 2009 Status Member Last seen November 6, 2009 - Nov 6, 2009 at 11:23 PM
Related:
- Excel macro copying cells based on criteria
- Excel macro to create new sheet based on value in cells - Guide
- Spell number in excel without macro - Guide
- Excel mod apk for pc - Download - Spreadsheets
- Excel marksheet - Guide
- Based on the values in cells b77 ✓ - Excel Forum
1 response
nsy2204
Posts
2
Registration date
Friday November 6, 2009
Status
Member
Last seen
November 6, 2009
1
Nov 6, 2009 at 11:23 PM
Nov 6, 2009 at 11:23 PM
I tried to do something like this but nothing seems to get copied...
Sub CopyData()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim j As Long, i As Long, lastrow As Long
Set sh1 = Worksheets("Worksheet A")
Set sh2 = Worksheets("Worksheet B")
lastrow = sh1.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
j = (i - 2) * 4 + 1
If sh1.Cells(i, "H").Value = sh2.Cells(j, "E").Value And _
sh1.Cells(i, "J").Value = sh2.Cells(j, "H").Value And _
sh1.Cells(i, "K").Value = sh2.Cells(j, "I").Value Then
sh1.Cells(i, "O").Copy sh2.Cells(j, "L")
End If
j = j + 4
Next
End Sub
Sub CopyData()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim j As Long, i As Long, lastrow As Long
Set sh1 = Worksheets("Worksheet A")
Set sh2 = Worksheets("Worksheet B")
lastrow = sh1.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
j = (i - 2) * 4 + 1
If sh1.Cells(i, "H").Value = sh2.Cells(j, "E").Value And _
sh1.Cells(i, "J").Value = sh2.Cells(j, "H").Value And _
sh1.Cells(i, "K").Value = sh2.Cells(j, "I").Value Then
sh1.Cells(i, "O").Copy sh2.Cells(j, "L")
End If
j = j + 4
Next
End Sub