Macro to move the data across the sheets in a workbook after searching the matching ID

Arunika

New Member
Joined
Jul 25, 2017
Messages
6
Hi ,

I am very new to VBA Coding .I am trying to write a macro to move the data across the sheets in a workbook .
There are two sheets Active and Resignees. When I enter the ID in Resignees sheet (Cell D1 ) it should search the ID in Active sheet (Sheet having complete headcount details ) and return me with certain columns only .

Please help me with the correction for the below code .

I have tried a code :

Sub Button38_Click()


Dim i As Long


With ThisWorkbook.Worksheets("Resigned Employees")

If (ThisWorkbook.Worksheets("Resigned Employees").Range("D1").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "A")) Then
For i = 2 To ThisWorkbook.Worksheets("Active Employee").Cells(.Rows.Count, "A").End(xlUp).Row




If Not IsEmpty(.Cells(i, "A").Value) Then

ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "A").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "A").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "B").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "B").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "C").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "C").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "D").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "D").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "E").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "H").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "F").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AG").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "G").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AI").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "H").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AJ").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "I").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AK").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "J").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AL").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "K").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AM").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "L").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AN").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "M").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "AO").Value
ThisWorkbook.Worksheets("Resigned Employees").Cells(i, "N").Value = ThisWorkbook.Worksheets("Active Employee").Cells(i, "BH").Value

Else
MsgBox "Not Found!"

End If
End If


Next i

End With
MsgBox "Entry Completed"
End Sub






Thanks in Advance .
 
Sorry, the offset should be 63 in the last example.
 
Last edited:
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top