How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.R. Jha Your Own Question

R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5471
Experience:  B.Tech
20870358
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

I need to write a vba code in the macro in Excel to achieve

This answer was rated:

I need to write a vba code in the macro in Excel to achieve data pulling from workbook 2, sheet 1, in to workbook 1, sheet 1.
I need to only copy start from workbook 2, sheet 1, B5 to the end of all the data in column X in to workbook 1, sheet 1, start from A2
workbook 2
A B C ....X
1 2 ....3
2 3 ....4
...........
4 5 ....6
Workbbok 1
name number ...State
1 2 ... 3
2 3 ....4
... ... .....
4 5 ....6
Hi,

I'd be glad to help. I'll work this out and get back to you soon.


Thanks
Customer: replied 3 years ago.


how is it going on

Working on it, would let you know soon.
Customer: replied 3 years ago.

how is it going on. I m wondering is that because i dong explain clearly? if so let me know i will explain a little bit more

Here it is. I assumed wb1 is the active workbook where data is to be pasted and wb2 is source workbook and is closed. Change wb2 to point to where source workbook is located

Sub myCopy()
Dim wb1 As Workbook, wb2 As Workbook
Dim copyRange As Range
Set wb1 = ActiveWorkbook
Set wb2 = Workbooks.Open("FULL PATH to WORKBOOK2")
wb2.Activate
Set copyRange = Sheets(1).Range("b5", Range("X65536").End(xlUp))
wb1.Activate
copyRange.Copy (wb1.Sheets(1).Range("a2"))
wb2.Close
End Sub


Thanks
Customer: replied 3 years ago.

Actually, i dont think the' Range("X65536").End(xlUp))' will work on the actual data. I have more 46 OR MORE COLUMNS IN THE real data, And the source workbook is to be refreshed with new data everymonth, which make the number of last row unknow. so I need a code to select from b5 to wherever the data end. and the end is unknow. I NEED code to command "go to the end of the data on the sheet"

Ok, I thought you mentioned column X. Let me change that
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
R.R. Jha and 2 other Homework Specialists are ready to help you