Hi,
Please have a look at the attached file, "HB Data" is the original sheet and got the following code from this forum
Sub check()
Position = 3
With Cells(5, 13)
Select Case Position
Case 1 To 4: .Value = Range("B2").Offset(0, Position).Value
Case Else: .Value = Range("G2").Value
End Select
End With
With Cells(6, 13)
Select Case Position
Case 1 To 3: .Value = Range("C2").Offset(0, Position).Value
Case Else: .Value = Range("G2").Value
End Select
End With
End Sub
The above code works fine if I have the data as per the 'HB Data' sheet, I know if additional data added as in the 'HB Data_new' then the above code won't work. So I need to convert the above code to dynamic.
Kindly help me please.
Originally I had
position=3
Cells(5, 13).Value = "=IF(" & Position = 1 & ",C2,IF(" & Position = 2 & ",D2,IF(" & Position = 3 & ",E2,IF(" & Position = 4 & ",F2,G2))))"
But it was not working, so I got help and above code from this forum.
Thanks
Bookmarks