You have this set up as a double-click event and the way you have it set up is that if you double click anywhere on the page, the code will execute. Do you wish to limit what kicks off the execution to a limited range of cells?
You have this set up as a double-click event and the way you have it set up is that if you double click anywhere on the page, the code will execute. Do you wish to limit what kicks off the execution to a limited range of cells?
This looks like it was a recorded macro. In general whenever you see:
You can replace it with
In a short program like this it doesn’t matter but if you are looping though thousands of cells of data, select will slow you down.
When working with multiple workbooks, it’s usually a good idea to set a “pointer” to them. The same holds true for worksheets.
In this case I have a pointer called xlFile to the workbook, and sh2 to a specific sheet in the workbook. The nice thing about pointers to sheets in workbook is that the pointer remembers which workbook it’s in. So if you want to copy something from sh1 in one workbook to sh2 in another use:
It doesn't matter if sh1 and sh2 are in the same workbook or not.
If you are copying all (meaning values, formats, formulas, etc.) then the shortcut for that is
If you just want to copy values then use
If you copy an entire row and you want to paste to an entire row, you don’t have to select the entire row for the destination. Selecting or addressing the first cell on the row is good enough.
Here is the code – complete with comments. Do not have the second file so I could not test this code.
Bookmarks