I am trying to copy all column data from column range A:AU of one excel to another excel in same range of column A:AU in which i have written the code .
Both excel are placed at different locations in my computer and i have written my vba code in the excel where i want to paste data, not in the excel from where i am copying the data.
name of excel from where i am copying the data is "EXRData_08.01.2018.xlsx" and sheet name is "EXR_extract_EX"
& the name of excel where i want to paste the data and where i have written my vba code is "UnattendedData.xlsm" and sheet name is "RawData" .
I am trying to copy entire column content from range A:AU from first excel and paste it into same range of A:AU in another excel where code is present but i am getting error and it is not running . kindly help me regarding this.
below is my code-
Sub panos() Dim r1 As Range, r2 As Range, N As Long Workbooks.Open "\01_Tool\Data\EXRData_08.01.2018.xlsx" N = Sheets("EXR_extract_EX").Cells(Rows.Count, "A:AU").End(xlUp).Row Set r1 = Sheets("EXR_extract_EX").Range("A:AU" & N) Workbooks.Open "_Master\Saurabh\UnattendedData.xlsm" Set r2 = Sheets("RawData").Range("A:AU") r1.Copy r2 End Sub
Range("A:AU" & N)is not a valid range it should be eitherRange("A:AU")for the full column or something likeRange("A" & N & ":AU" & N). I also recommend to use the full file path inWorkbooks.Openand specify the workbook for Sheets otherwise you will run into issues. Also theUnattendedData.xlsmdoesn't need to be opened, because this is already opened as you run the code from this file as you wrote.