msknvg
01-04-2023, 06:03 AM
Hello guys,
Probably this is a dumb question but i am starting a new job and its my first time with VBA.
Basically, there is an excel file that is constantly updated. I need to copy the last 3 columns of that file to another excel. As simple as that, but my code isn't working... I'm testing with just one column, and it still doesn't work.
I leave the code below.
I can't understand how to define the some stuff that i mention in
Sub Copy()
Dim lCol As Range
lCol = Cells(1, Columns.Count).End(xlToLeft).EntireColumn
(how to define the second column?)
(how to define the third column?)
Range("how to define the range of 3 columns?").Select
Selection.Copy
Application.WindowState = xlNormal
Windows("Teste 2.xlsx").Activate
Range("D1").Select
ActiveSheet.Paste
Windows("Teste 1.xlsx").Activate
End Sub
I don't know how to define the things I mention in italics.
I don't know if it was too confusing but I would be grateful with any help.
Probably this is a dumb question but i am starting a new job and its my first time with VBA.
Basically, there is an excel file that is constantly updated. I need to copy the last 3 columns of that file to another excel. As simple as that, but my code isn't working... I'm testing with just one column, and it still doesn't work.
I leave the code below.
I can't understand how to define the some stuff that i mention in
Sub Copy()
Dim lCol As Range
lCol = Cells(1, Columns.Count).End(xlToLeft).EntireColumn
(how to define the second column?)
(how to define the third column?)
Range("how to define the range of 3 columns?").Select
Selection.Copy
Application.WindowState = xlNormal
Windows("Teste 2.xlsx").Activate
Range("D1").Select
ActiveSheet.Paste
Windows("Teste 1.xlsx").Activate
End Sub
I don't know how to define the things I mention in italics.
I don't know if it was too confusing but I would be grateful with any help.