Find and Paste the values from one Excel to Another

venugosr

New Member
Joined
Jul 9, 2014
Messages
46
Hi Team,

I need a help to copy and paste the values from One excel to another.
1. I have two excel sheet. One contains master data and other one need to send the details to client.
2. In the mater data i have columns ( Name, Emp id, No of days worked and Hours, etc) with emp details
3. The other one contains the same columns, but the emp details in different order.
4. From the master sheet i want to copy and pate the No of days worked and Hours to other sheet.
5. Now im doing copy and find and then pasting the details. It takes time. Will you help me to automate this process?
6. I have one coding, but it copy and paste the whole data from one excel to another. Please find the coding as well.

Kindly help me on this.

Thanks in advance.

Srikanth.V

Code:
<dl class="codebox"><dd><code>Sub copydata()
Dim wkbSource As Workbook
Dim wkbDest As Workbook
Dim shttocopy As Worksheet
Dim wbname As String
' check if the file is open
ret = Isworkbookopen("H:\Srikanth\Book2.xlsm")
If ret = False Then
' open file
Set wkbSource = Workbooks.Open("H:\Srikanth\Book2.xlsm")
Else
'Just make it active
'Workbooks("C:\stack\file1.xlsx").Activate
Set wkbSource = Workbooks("Book2.xlsm")
End If
' check if the file is open
ret = Isworkbookopen("H:\Srikanth\Book1.xlsx")
If ret = False Then
' open file
Set wkbDest = Workbooks.Open("H:\Srikanth\Book1.xlsx")
Else
'Just make it active
'Workbooks("C:\stack\file2.xlsx").Activate
Set wkbDest = Workbooks("Book1.xlsx")
End If
'perform copy
Set shttocopy = wkbSource.Sheets("filedata")
shttocopy.Copy wkbDest.Sheets(3)
End Sub
Function Isworkbookopen(filename As String)
Dim ff As Long, ErrNo As Long
Dim wkb As Workbook
Dim nam As String
wbname = filename
On Error Resume Next
ff = FreeFile()
Open filename For Input Lock Read As #ff
Close ff
ErrNo = Err
On Error GoTo 0
Select Case ErrNo
Case 0: Isworkbookopen = False
Case 70: Isworkbookopen = True
Case Else: Error ErrNo
End Select
End Function</code>
</dd></dl>
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,222,436
Messages
6,166,020
Members
452,008
Latest member
Customlogoflipflops

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