Hi, I previously posted this question in another thread. At the suggestion of the user attempting to answer the question I have reviewed the way the way I am asking the question (as there was some confusion) and started fresh here.
I have a workbook, in which the first sheet will be raw data, and then a sheet which will perform a series of calculations on data entered into it. There might be several dozen copies of this second sheet (varying from project to project), always performing the same calculations, but on different parts of the raw data. I need to copy in the sections of raw data to each sheet to calculate my various results. At the moment I have to search through my data, which could be hundreds or even thousands of rows long, highlight and copy the section I need to the relevant area of the relent sheet. Iam trying to write a VBA to speed this process up.
I have attached an example workbook. This is simplified in terms of the amount of data, the calculations which the successive sheets are performing and the exact locations of the elements but the principle is the same.
I would like to be able to enter two variables on a sheet. One to select the file number of the raw data, and one to set the location to paste. Hopefully the following images show this idea
Enter variable sheet2 (the active sheet in this example):
Variable.JPG
Source data to be copied based on variable in cell A1 sheet1 (the raw data)
Source.JPG
Pasted data in sheet2 (the active sheet in this example)
Outcome.JPG
To populate each location in a given calculation sheet I would re-enter the variable and re-run the macro (assigned to a keyboard shortcut). It does not have to copy to different locations or different sheets at the same time.
At the moment I have the following code:
This selects a range of values from the raw data page sheet1 (a 4x4 grid), based on the file number in column A being matched to the value of cell A1 in the activesheet (the first two columns are ignored using the offset), and copies it to a fixed grid of cells in whatever the active sheet is.
What I need is for the location in which the values are pasted to to be chosen by the variable entered in cell B1 of the active sheet matching to the corresponding location name in columnC of the active sheet (with the values then pasted starting in the adjacent cell). So if I enter 10 in A1, and B in B1 in the active sheet the code will search for file 10 in column A sheet1, skip the first two columns, copy a 4x4 grid of values, then paste these into the location b box, starting in the cell to the right of 'B'.
Does anyone know how to adapt the code above to achieve this?
Also, it would be useful to know if there is a more efficient way of picking the range to be copied instead of having to type out the individual offset.copy for each cell.
Please let me know if I can clarify anything further.
Bookmarks