Hello,
I'm trying to rearrange data with macro code something like below:
For this matter, I wrote a macro code:
When I start macro command, It finds first value (Max Voltage L1) but doesn't find other values (Max Voltage L2-3), gives an error:
Could you help me solve this problem?
Thank you!
I'm trying to rearrange data with macro code something like below:
For this matter, I wrote a macro code:
VBA Code:
Sub Sample()
Dim ws As Worksheet
Dim LastRow4 As Long
Dim LastRow5 As Long
Dim LastRow6 As Long
Dim LastRow7 As Long
Dim LastColumn As Long
Dim col As Long
Dim row As Long
With ws
LastRow4 = .Range("F" & .Rows.Count).End(xlUp).row
LastRow5 = .Range("E" & .Rows.Count).End(xlUp).row
LastRow6 = .Range("D" & .Rows.Count).End(xlUp).row
LastRow7 = .Range("C" & .Rows.Count).End(xlUp).row
LastColumn = .Range("G5").End(xlToRight).Column
For col = 7 To LastColumn
For row = 6 To LastRow4
.Range(Cells(row, col), Cells(row, col)).Value = Application.WorksheetFunction.Index(.Range(Cells(6, 5), Cells(LastRow5, 5)), _
Application.WorksheetFunction.Match(.Range(Cells(row, 6), Cells(row, 6)), .Range(Cells(6, 4), Cells(LastRow6, 4)), 0), _
Application.WorksheetFunction.Match(.Range(Cells(5, col), Cells(5, col)), .Range(Cells(6, 3), Cells(LastRow7, 3)), 0))
Next row
Next col
End With
End Sub
When I start macro command, It finds first value (Max Voltage L1) but doesn't find other values (Max Voltage L2-3), gives an error:
Could you help me solve this problem?
Thank you!