copy and paste

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

copy and paste

Post by zyxw1234 »

vba will be placed in a seperate file macro.xlsm
i have three files 1.xls & 2.csv & 3.xlsx
1.xls first row has headers so dont count that
In 1.xls count the total number of rows that has data and copy the 3.xlsx sheet3 first row(first complete row copy) and paste that much time of 3.xlsx first row of sheet3 to 2.csv
suppose 1.xls has data in 5 rows then copy 3.xlsx first row of sheet3 and paste it to 2.csv 5 times
all files are located in a different path
sheet name can be anything
plz see the sample file
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78230
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: copy and paste

Post by HansV »

Please make a start writing the code, and come back if you have specific questions.
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: copy and paste

Post by zyxw1234 »

Code: Select all

Sub STEP4()
 Dim w1 As Workbook, w2 As Workbook, w3 As Workbook
 Set w1 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\1.xlsx") 
 Set w2 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\document\2.csv")
 Set w3 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\files\3.xlsx")
 Dim Ws1 As Worksheet, Ws2 As Worksheet, Ws3 As Worksheet
 Set Ws1 = w1.Worksheets.Item(1)
 Set Ws2 = w2.Worksheets.Item(1)
 Set Ws3 = w3.Worksheets.Item(1)



w1.Close
w2.Save
Let Application.DisplayAlerts = False
w2.Close
Let Application.DisplayAlerts = True
w3.Close


End Sub

HansV Sir i need the middle part for the same

User avatar
HansV
Administrator
Posts: 78230
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: copy and paste

Post by HansV »

OK, that's a good beginning. Now, please start writing some of the code for the middle.
You and your predecessors (leonardo1234, roger@ etc.) have already have a lot of help with similar questions.
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: copy and paste

Post by zyxw1234 »

Sir i am new to vba
i don't know much
what i have leraned i putted the same HansV Sir

User avatar
HansV
Administrator
Posts: 78230
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: copy and paste

Post by HansV »

If you're not willing or able to learn to write your own code, we cannot help you. Providing complete solutions is not the purpose of these forums. I have pointed that out several times before.
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: copy and paste

Post by zyxw1234 »

No Problem HansV Sir
Thnx Alot for helping me in solving this problem Sir
Have a Great Day