The below code works perfectly but when doing 20 odd thousand rows it takes a good bit of time so I was just seeing if there was a more efficient method of doing same thing.
Sub CopySensToReleventCell() '
Dim i As Long
Dim y As Integer
cgws.Select 'selecting results worksheet
For i = 2 To CalcRowscgr ' For statement from 2 to total number of rows in sheet
If Cells(i, 2) = "" Then 'column 9 should have a value but sometimes wont for various reasons
Cells(i, 2) = "NR" 'Put NR in where there was a blank because result maybe too weak
End If
For y = 3 To cgws.UsedRange.Columns.Count
' starts at col 3 and counts number of columns (currently 25) incase of additional column required
If Cells(i, 1) = Cells(1, y) Then 'if test code in column matched top row of same process
Cells(i, y) = Cells(i, 2) ' copy into cell under relevant result
Exit For ‘exits y for loop
End If
Next y
Next i
End Sub
Eg below
Start
<tbody>
</tbody>
End result
<tbody>
</tbody>
Sub CopySensToReleventCell() '
Dim i As Long
Dim y As Integer
cgws.Select 'selecting results worksheet
For i = 2 To CalcRowscgr ' For statement from 2 to total number of rows in sheet
If Cells(i, 2) = "" Then 'column 9 should have a value but sometimes wont for various reasons
Cells(i, 2) = "NR" 'Put NR in where there was a blank because result maybe too weak
End If
For y = 3 To cgws.UsedRange.Columns.Count
' starts at col 3 and counts number of columns (currently 25) incase of additional column required
If Cells(i, 1) = Cells(1, y) Then 'if test code in column matched top row of same process
Cells(i, y) = Cells(i, 2) ' copy into cell under relevant result
Exit For ‘exits y for loop
End If
Next y
Next i
End Sub
Eg below
Start
Code | Result | AMI | AMO | AMP | CAX | CTP | CNO | DNo |
AMI | S | |||||||
AMP | s | |||||||
CAX | R | |||||||
DNo | NR |
<tbody>
</tbody>
End result
Code | Result | AMI | AMO | AMP | CAX | CTP | CNO | DNo |
AMI | S | S | ||||||
AMP | s | s | ||||||
CAX | R | R | ||||||
DNo | NR | NR |
<tbody>
</tbody>