Thomas Kuriakose
Active Member
Dear All
Please find attached an incomplete code for transfer data to one sheet from multiple sheets based on a lookup reference. If the selected commission number is found it should copy the data from column C to K for the specific commission number to the summary sheet. It should also copy the corresponding value from B1 to B3 to he respective summary sheet cell.
Kindly help to correct the errors and in the result.
thanks,
with regards,
thomas
Please find attached an incomplete code for transfer data to one sheet from multiple sheets based on a lookup reference. If the selected commission number is found it should copy the data from column C to K for the specific commission number to the summary sheet. It should also copy the corresponding value from B1 to B3 to he respective summary sheet cell.
Code:
Sub transfer()
Dim ws As Worksheet, myCounter
Dim erow, myValue As Long
For Each ws In Sheets
If ws.Range("B1").Value = "S001" Then
myCounter = 1
ws.Select
ws.Range("B6").Select
myValue = ws.Range("B6").Value
Worksheets("Lookup Table").Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1) = myValue
nextValue = MsgBox("Value found in " & ws.Name & Chr(10) & _
"Continue?", vbInformation + vbYesNo, _
ws.Name & " B1 = " & ws.Range("B1").Value)
Select Case nextValue
Case Is = vbYes
Case Is = vbNo
Exit Sub
End Select
End If
Next ws
If myCounter = 0 Then
MsgBox "None of the sheets contains a " & Chr(10) & _
"Mentioned Commission Number in cell C6 ", vbInformation, "Not Found"
End If
End Sub
Kindly help to correct the errors and in the result.
thanks,
with regards,
thomas