Hi,
I've avoided posting my own thread for years when it has come to excel help, but this time I am really stuck. I am not too experienced with macros... I'll typically look for an alternative solution or else I record simply copy/delete/hide etc. macros using excel's 'Record Macro'.
I have created a costing program in excel for the industry I'm in which is intended to cost out hundreds of products through the use of individual 12 col/40 row template. Starting with a template range of A1:O40 (Columns L,M,N are always hidden, but must be copied with the rest of the range) I will select the entire range ctrl-c, ctrl-v into cell A41, which duplicates the former range in it's entirety with identical functionality. I use different worksheets for different categories, but products within the same category are copy and pasted directly below one another (A1,A41,A81,A121 etc.). Functionally, the system works fine, however I've been trying to find a way where I can add 3 buttons along the top of each template which will be labeled: DELETE, COPY, NEW.
Here's what I need the macro's to do:
DELETE: I need this macro to be able to delete the row numbers belonging to the current product template being used (ex. If I want to delete the template for the product which is in range A41:080, I could click a button w/ assigned macro within that template to remove the desired rows). Since I'm not sure sure whether a macro can determine the row number of where a button was clicked and delete that row + 39 below it, I was thinking I could add a confirmation cell. In cell G1 (and G41, G81, G121 etc.) I can have the user type "DEL" and then activate the macro. The macro would scan 'Column G' for "DEL" and when it finds it, it would delete that row + the 39 below it? Is this possible?
COPY: Similarly, in J1 (and J41, J81, J121 etc.) I would have the user type "COPY" on the template they wish to copy and activate the copy macro which would scan 'Column J' for "COPY" and when it finds it, it would select that row + the 39 below it and insert that copied range after the last row containing data, and lastly, remove the text "COPY" from the original template and the new.
NEW: This macro needs to copy Rows 1-40 and insert that copied range after the last row containing data, and then delete cell values in these ranges + the row number it was pasted in - 1: (A4, A14:C28, B31:C36, B39:D40, I4:I10, O4:O10, G14, G16, G19, G21, G23:G24, G26, G32:I40 on the original template) so if it was pasted into Row41 (41-1=40) then the values would be (A5, A54-C68, B71:C76, B79:D80, I44:I50, G54, G56, G59, G61, G63:G64, G66, G72:I80).
Unfortunately I can not share the workbook as it contains confidential costing information, but hopefully I have done a well enough job explaining what I am trying to achieve. Let me know if anyone needs anymore details.
I'll gladly take any help I can get on any of these 3 macros I have described.
Thank you so much,
Stephen
I've avoided posting my own thread for years when it has come to excel help, but this time I am really stuck. I am not too experienced with macros... I'll typically look for an alternative solution or else I record simply copy/delete/hide etc. macros using excel's 'Record Macro'.
I have created a costing program in excel for the industry I'm in which is intended to cost out hundreds of products through the use of individual 12 col/40 row template. Starting with a template range of A1:O40 (Columns L,M,N are always hidden, but must be copied with the rest of the range) I will select the entire range ctrl-c, ctrl-v into cell A41, which duplicates the former range in it's entirety with identical functionality. I use different worksheets for different categories, but products within the same category are copy and pasted directly below one another (A1,A41,A81,A121 etc.). Functionally, the system works fine, however I've been trying to find a way where I can add 3 buttons along the top of each template which will be labeled: DELETE, COPY, NEW.
Here's what I need the macro's to do:
DELETE: I need this macro to be able to delete the row numbers belonging to the current product template being used (ex. If I want to delete the template for the product which is in range A41:080, I could click a button w/ assigned macro within that template to remove the desired rows). Since I'm not sure sure whether a macro can determine the row number of where a button was clicked and delete that row + 39 below it, I was thinking I could add a confirmation cell. In cell G1 (and G41, G81, G121 etc.) I can have the user type "DEL" and then activate the macro. The macro would scan 'Column G' for "DEL" and when it finds it, it would delete that row + the 39 below it? Is this possible?
COPY: Similarly, in J1 (and J41, J81, J121 etc.) I would have the user type "COPY" on the template they wish to copy and activate the copy macro which would scan 'Column J' for "COPY" and when it finds it, it would select that row + the 39 below it and insert that copied range after the last row containing data, and lastly, remove the text "COPY" from the original template and the new.
NEW: This macro needs to copy Rows 1-40 and insert that copied range after the last row containing data, and then delete cell values in these ranges + the row number it was pasted in - 1: (A4, A14:C28, B31:C36, B39:D40, I4:I10, O4:O10, G14, G16, G19, G21, G23:G24, G26, G32:I40 on the original template) so if it was pasted into Row41 (41-1=40) then the values would be (A5, A54-C68, B71:C76, B79:D80, I44:I50, G54, G56, G59, G61, G63:G64, G66, G72:I80).
Unfortunately I can not share the workbook as it contains confidential costing information, but hopefully I have done a well enough job explaining what I am trying to achieve. Let me know if anyone needs anymore details.
I'll gladly take any help I can get on any of these 3 macros I have described.
Thank you so much,
Stephen
Last edited: