I am trying to create a macro which selects specific columns in one workbook and then in another workbook according to the column the data is pasted, as the columns are different in both workbooks.
I am able to select in Workbook 1; column C and in Workbook 2 column Z3 and paste the values; but for this I have to highlight all the values in Workbook 1: Column C and then run the macro.
I don't know how to create a macro which does this on click- automatically and also for multiple columns. Below I have included the code that works when the values are selected,
Range("C47:C581").Select
Selection.Copy
Windows("Workbook2.xls").Activate
Range("Z3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Workbook1.xlsm").Activate
I am not able to include images so i will explain below using examples. Below is what Workbook 1 Sheet 1.
Column A Column B Column C Column
1 1 11 5555
2 2 22 4444
2 3 33 3333
I want to create a macro that finds the number of cells in Column A (not including the heading) and pastes them into Workbook 2 Column C . The code above in my description only works for a specified range; i have tried the NumberOfCells but i am not sure why this doesn't work
Selection.Copytoworkbooks("Workbook1.xlsm").Sheets("Sheet1").Columns(3).copy