Copy paste by vba

L

Legacy 450448

Guest
my files
target1.xlsx
target2.xlsx
macro.xlsm
If column E of target1.xlsx matches with column A of target2.xlsx then copy and paste the column R data of target1.xlsx to target2.xlsx from column C(if column C has data then column D and if column D has then from column E and so on...)
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You don't want to copy and paste.

You want to use two ranges, and set the value of one to the other.

so you'd want something like this....

Code:
Sub Mysub

dim wb1 as workbook
dim wb2 as workbook

set wb1 = [your path]target1.xlsx
set wb2 = [your path]target2.xlsx

If wb1.[Your logic] then

   wb2.column(your column).value - wb1.(your column).value

end if

end sub
 
Upvote 0
sir plz have a relook to my questions the given code is just an idea (basics) and i know that sir but i am not a professional vba programmer like u so i am unable to write the code for this so plz help sir
Thnx in advance
 
Upvote 0
I tried i got this plz have a look and help Sir

Sub Mysub

dim wbk1 as workbook
dim wbk2 as workbook

Application.ScreenUpdating = False

Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\target1.xlsx")
Set wsh1 = wbk1.Worksheets(1)

Set wbk2 = Workbooks.Open(ThisWorkbook.Path & "\target2.xlsx")
Set wsh2 = wbk2.Worksheets(1)


If wbk1.[my logic] then

wbk2.column(my column).value - wbk1.(my column).value

end if

Application.DisplayAlerts = False
wbk1.Close SaveChanges:=True
wbk2.Close SaveChanges:=True
Application.DisplayAlerts = True

Application.ScreenUpdating = True

end sub




so plz have a look and help Sir
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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