![]() |
Program a macro to run at specific instances
I have a macro that hides blank rows whenever there is no value in a
particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B (Let me know if I need to explain some more) |
Program a macro to run at specific instances
"Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened Add the code in workbook_open Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B How would they enter data in B if it is hidden? any cell? |
Program a macro to run at specific instances
Try copying the macro into the "this workbook" code sheet. Select the
"Workbook" option in the upper Left drop down box, and select "open" from the upper right drop down box. Then stick you code in between the statements that are generated. This is an event procedure that take place whenever something happens, in this case the wkbook opens. For the second part, very similar. Activate the code sheet for the specific sheet. Select the "Worksheet" option in the upper Left drop down box, and select "change" from the upper right drop down box. Then stick you code in between the statements that are generated Let me know if this works for you. "Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B (Let me know if I need to explain some more) |
Program a macro to run at specific instances
Thanks for the help on the first question, was just what I needed.
To give more details for my second question, the spreadsheet with the macro that hides blank cells is linked to another workbook whereby users enter data. If they don't enter data on some rows, the macro hides these rows. Currently I have been running the macro manually and wanted to automate it. So the trigger to unhide the rows is actually when either the user enters data or when I open the workbook. I was thinking of instances when both workbooks are open, to automate the macro whenever there is a change in the range of B Cells of the initial workbook, which is what tells the macro whether or not to hide a row. (Not sure if it is clear - let me know) "Bob Phillips" wrote: "Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened Add the code in workbook_open Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B How would they enter data in B if it is hidden? any cell? |
Program a macro to run at specific instances
Thanks for the help on the first question, was just what I needed which you
both suggested. Unfortunately, the problem with pasting the macro in the Worksheet Change area, it keeps running the macro everytime I click on a cell which is a bit too much - I want it to only run when there is a change in data in the B column (I have a specific range the macro looks at) which is what tells the macro whether or not to hide a row. (Let me know if I need to explain some more) "AD108" wrote: Try copying the macro into the "this workbook" code sheet. Select the "Workbook" option in the upper Left drop down box, and select "open" from the upper right drop down box. Then stick you code in between the statements that are generated. This is an event procedure that take place whenever something happens, in this case the wkbook opens. For the second part, very similar. Activate the code sheet for the specific sheet. Select the "Worksheet" option in the upper Left drop down box, and select "change" from the upper right drop down box. Then stick you code in between the statements that are generated Let me know if this works for you. "Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B (Let me know if I need to explain some more) |
Program a macro to run at specific instances
I take it you got your answer according to the other thread in the other
group? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Chiku" wrote in message ... Thanks for the help on the first question, was just what I needed. To give more details for my second question, the spreadsheet with the macro that hides blank cells is linked to another workbook whereby users enter data. If they don't enter data on some rows, the macro hides these rows. Currently I have been running the macro manually and wanted to automate it. So the trigger to unhide the rows is actually when either the user enters data or when I open the workbook. I was thinking of instances when both workbooks are open, to automate the macro whenever there is a change in the range of B Cells of the initial workbook, which is what tells the macro whether or not to hide a row. (Not sure if it is clear - let me know) "Bob Phillips" wrote: "Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened Add the code in workbook_open Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B How would they enter data in B if it is hidden? any cell? |
Program a macro to run at specific instances
I still need help with the second question on running the macro when there is
a change in cells within a particular range - is it possible to program the macro to run only when there is a change in column B of the table? What I mean is, this worksheet is linked to another such that when a user enters data, it is also displays in the worksheet where I have the macro. So, I want the macro to run, when previously empty cells in column B get data. Is that possible? "Bob Phillips" wrote: I take it you got your answer according to the other thread in the other group? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Chiku" wrote in message ... Thanks for the help on the first question, was just what I needed. To give more details for my second question, the spreadsheet with the macro that hides blank cells is linked to another workbook whereby users enter data. If they don't enter data on some rows, the macro hides these rows. Currently I have been running the macro manually and wanted to automate it. So the trigger to unhide the rows is actually when either the user enters data or when I open the workbook. I was thinking of instances when both workbooks are open, to automate the macro whenever there is a change in the range of B Cells of the initial workbook, which is what tells the macro whether or not to hide a row. (Not sure if it is clear - let me know) "Bob Phillips" wrote: "Chiku" wrote in message ... I have a macro that hides blank rows whenever there is no value in a particular cell. Two things: 1.) How do I program the macro to run everytime the file is opened Add the code in workbook_open Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code 2.) How do I also program the macro to run every time someone adds a value in any of the cells that determine whether its row should be hidden? In other words, column B contains the cells in which when blank, the row is hidden. Now I want to unhide the row if someone enters data in the cell in column B How would they enter data in B if it is hidden? any cell? |
All times are GMT +1. The time now is 07:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com