Hi,
I think maybe you have got something mixed up or wrong….
The macro you posted seems unnecessarily very complicate. It may be complicated for reasons and issues that I do not know about. That is why , as ever, it is always important for me to know where you got the macro from
Where did you get this macro from?
Are you sure that your explanation is correct? I think that is probably not what you want. If it is then that macro you posted is probably not the one that you meant to…
Copy column B data of 1.xls and paste it to column C of basketorder.xlsx(exclude the header of column B of 1.xls and simply paste the rest data to column C of basketorder.xlsx
= copy 1.xls B2:B5 to C1:C4 BasketOrder.xlsx
If that is what you want , then you need just one code line like
' https://excelfox.com/forum/showthrea...ll=1#post14104
Ws2.Range(“C1:C4”).Value = Ws1.Range(“B2:B5”)
Or like
' https://excelfox.com/forum/showthrea...ll=1#post14100
Ws1.Range(“B2:B5”).Copy
Ws2.Range(“C1:C4”) .PasteSpecial Paste:= xlPasteValues
That you have been doing that now for 2 years, here one example https://excelfox.com/forum/showthrea...ll=1#post14104
https://excelfox.com/forum/showthrea...ll=1#post14100 .
I and others have shown you how to do that 100 times.
( And you just need to make the last row dynamic)
Alan
Code:
Sub DimPigSht4Brains1()
Dim Ws1 As Worksheet, Ws2 As Worksheet, Lr1 As Long, Lr2 As Long
Set Ws1 = Workbooks("1.xls").Worksheets.Item(1): Set Ws2 = Workbooks("BasketOrder.xlsx").Worksheets.Item(1)
Let Lr1 = Ws1.Range("A" & Ws1.Rows.Count).End(xlUp).Row: Let Lr2 = Ws2.Range("A" & Ws1.Rows.Count).End(xlUp).Row
Let Ws2.Range("C1:C4").Value = Ws1.Range("B2:B5").Value
End Sub
Sub DimPigSht4Brains2()
Dim Ws1 As Worksheet, Ws2 As Worksheet, Lr1 As Long, Lr2 As Long
Set Ws1 = Workbooks("1.xls").Worksheets.Item(1): Set Ws2 = Workbooks("BasketOrder.xlsx").Worksheets.Item(1)
Let Lr1 = Ws1.Range("A" & Ws1.Rows.Count).End(xlUp).Row: Let Lr2 = Ws2.Range("A" & Ws1.Rows.Count).End(xlUp).Row
Ws1.Range("B2:B5").Copy
Ws2.Range("C1:C4").PasteSpecial Paste:=xlPasteValues
End Sub
Bookmarks