copy and paste

0

all files are located same place

vba is placed in a seperate file sample1.xlsm

copy all the data from column A TO COLUMN H complete data from sample2.xls and paste it to sample3.xlsb in same columns

save and close the sample2.xls and sample3.xlsb

i need to do the same by vba so plz help me in slving this problem sir

Answer
Discuss

Discussion

Rider, you have become so advanced now that you can't any longer ask the right questions without some knowledge of VBA. Please start programming a solution. It doesn't need to be workable code. I'll fix that for you. But at least you will have an inkling of what problems there are, meaning, at least you will have a vague idea of what you are asking.
Variatus (rep: 4864) Mar 2, '20 at 6:53 am
Sub CopyData()
 Dim w1 As Workbook, w2 As Workbook
 Set w1 = Workbooks.Open("C:\a.xlsx") ' change the file path
 Set w2 = Workbooks.Open("C:\c.xlsx") ' change the file path
w2.Worksheets(1).Range("A1:H" & w2.Worksheets(1).Rows.Count) = _
w1.Worksheets(1).Range("A1:H" & w1.Worksheets(1).Rows.Count).Value

With w1: .Save: .Close: End With
With w2: .Save: .Close: End With

End Sub
rider1234 (rep: 8) Mar 2, '20 at 7:15 am
this code is no perfect mistake is there plz check
rider1234 (rep: 8) Mar 2, '20 at 7:15 am
Your code is a vital part of your question. To conform with forum rules please add it to your question. Nobody wants to dig for it in the Discussion section where it can be deleted. You may like to review it before posting. At a quick glance, there is no similarity between your question and this code, fortifying my argument. It might be helpful if you add comments, which lines of your code are supposed to copy data from column A to column H, which lines "complete the data from sample2" and which lines then "paste it to sample3".
Variatus (rep: 4864) Mar 2, '20 at 7:45 pm
Sub STEP4()
 Dim w1 As Workbook, w2 As Workbook
 Set w1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls") ' change the file path
 Set w2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\FundsCheck.xlsb") ' change the file path
w1.Worksheets.Item(1).Columns("A:H").Copy
w2.Worksheets.Item(1).Columns("A:H").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
w2.Save
w2.Close
w1.Close 
End Sub
style36 (rep: 24) Mar 2, '20 at 11:53 pm
Add to Discussion

Answers

0
Sub STEP4()
 Dim w1 As Workbook, w2 As Workbook
 Set w1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls") ' change the file path
 Set w2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\FundsCheck.xlsb") ' change the file path
w1.Worksheets.Item(1).Columns("A:H").Copy
w2.Worksheets.Item(1).Columns("A:H").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
w2.Save
w2.Close
w1.Close 
End Sub
Discuss

Discussion

Problem Solved
style36 (rep: 24) Mar 2, '20 at 11:53 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login