Hi,
I have this code, which works great if the data is always the same size, however on this particular case the range i'm copying can change (everyday will have more lines - columns remain the same) and therefore this will affect:
original range is dynamic:
Windows("data1.xlsx").Activate
Range("A1:C4").Select
Selection.Copy
cell where the 2nd range will be copied to will have start on a different variable cell:
Windows("master.xlsm").Activate
Range("F14").Select
ActiveSheet.Paste
and finally the ending range will also be dynamic.
Range("F10:H17").Select
ActiveWorkbook.Names.Add Name:="grupo", RefersToR1C1:="=Folha1!R10C6:R17C8"
ActiveWorkbook.Names("grupo").Comment = ""
Is it possible to change the code so that it will adapt to these dynamic ranges?
Any help would be appreciated. Thx in advance.
Best regards
Full code:
Sub Macro1()
'
' Macro1 Macro
'
'
Windows("data1.xlsx").Activate
Range("A1:C4").Select
Selection.Copy
Windows("master.xlsm").Activate
Range("F10").Select
ActiveSheet.Paste
Windows("data2.xlsx").Activate
Range("A2:C5").Select
Selection.Copy
Windows("master.xlsm").Activate
Range("F14").Select
ActiveSheet.Paste
Range("F10:H17").Select
ActiveWorkbook.Names.Add Name:="grupo", RefersToR1C1:="=Folha1!R10C6:R17C8"
ActiveWorkbook.Names("grupo").Comment = ""
End Sub
I have this code, which works great if the data is always the same size, however on this particular case the range i'm copying can change (everyday will have more lines - columns remain the same) and therefore this will affect:
original range is dynamic:
Windows("data1.xlsx").Activate
Range("A1:C4").Select
Selection.Copy
cell where the 2nd range will be copied to will have start on a different variable cell:
Windows("master.xlsm").Activate
Range("F14").Select
ActiveSheet.Paste
and finally the ending range will also be dynamic.
Range("F10:H17").Select
ActiveWorkbook.Names.Add Name:="grupo", RefersToR1C1:="=Folha1!R10C6:R17C8"
ActiveWorkbook.Names("grupo").Comment = ""
Is it possible to change the code so that it will adapt to these dynamic ranges?
Any help would be appreciated. Thx in advance.
Best regards
Full code:
Sub Macro1()
'
' Macro1 Macro
'
'
Windows("data1.xlsx").Activate
Range("A1:C4").Select
Selection.Copy
Windows("master.xlsm").Activate
Range("F10").Select
ActiveSheet.Paste
Windows("data2.xlsx").Activate
Range("A2:C5").Select
Selection.Copy
Windows("master.xlsm").Activate
Range("F14").Select
ActiveSheet.Paste
Range("F10:H17").Select
ActiveWorkbook.Names.Add Name:="grupo", RefersToR1C1:="=Folha1!R10C6:R17C8"
ActiveWorkbook.Names("grupo").Comment = ""
End Sub