ryancdavis
New Member
- Joined
- Jun 29, 2017
- Messages
- 8
Hello -
Thank you for any help in advance. I'm still trying to learn VBA and have been trying to figure this out for a while - and need some help.
I am trying to make certain fields required before the user can access the print button I created using the form tools on a specific worksheet. To reduce headaches moving forward, I was thinking about creating a macro that would check a specific worksheet based on a predefined "RGB ColorIndex" for required fields. I'll color all required fields this predefined color, which will require input prior to the user being able to access the print/submit button(s) I created within this specific sheet.
My thoughts are that this will help me later if changes are made on the worksheet (e.g. new fields added, reorganizing fields, or not requiring certain fields any longer) - so all I will have to do is ensure a required cell is colored correctly which would make it required automatically per the VBA code. This would save a lot of time, rather than defining an array of specific cells that will have to be manually updated every time a change is made to the worksheet.
Does anyone have any ideas on how to achieve this?
In summary, the logic in my mind is below. I just don't know how to put this into a working VBA script.
> Check range on worksheet named "X" for cells with specific color index.
> All cells that are equal to the color index predefined for this specific worksheet are required, so check these fields for input (not blank or empty).
> If cells with predefined color index are empty, then hide/disable the print button I created on the worksheet and notify user in message box which cells require input.
> Else, if some required fields have input, but not all required fields, then notify user in a message box stating the fields that require input.
> Else, if all required fields have input, then show/enable the print button.
I'm guessing it would be okay to put this under the Worksheet_Change sub, but feel that could cause the error message to popup every time a user begins filling out the blank worksheet with information - becoming annoying and inefficient. Is there a better worksheet specific sub to put this under?
Hopefully, this makes sense on what I am trying to achieve. Thank you community for all the help and assistance!
- RD
Thank you for any help in advance. I'm still trying to learn VBA and have been trying to figure this out for a while - and need some help.
I am trying to make certain fields required before the user can access the print button I created using the form tools on a specific worksheet. To reduce headaches moving forward, I was thinking about creating a macro that would check a specific worksheet based on a predefined "RGB ColorIndex" for required fields. I'll color all required fields this predefined color, which will require input prior to the user being able to access the print/submit button(s) I created within this specific sheet.
My thoughts are that this will help me later if changes are made on the worksheet (e.g. new fields added, reorganizing fields, or not requiring certain fields any longer) - so all I will have to do is ensure a required cell is colored correctly which would make it required automatically per the VBA code. This would save a lot of time, rather than defining an array of specific cells that will have to be manually updated every time a change is made to the worksheet.
Does anyone have any ideas on how to achieve this?
In summary, the logic in my mind is below. I just don't know how to put this into a working VBA script.
> Check range on worksheet named "X" for cells with specific color index.
> All cells that are equal to the color index predefined for this specific worksheet are required, so check these fields for input (not blank or empty).
> If cells with predefined color index are empty, then hide/disable the print button I created on the worksheet and notify user in message box which cells require input.
> Else, if some required fields have input, but not all required fields, then notify user in a message box stating the fields that require input.
> Else, if all required fields have input, then show/enable the print button.
I'm guessing it would be okay to put this under the Worksheet_Change sub, but feel that could cause the error message to popup every time a user begins filling out the blank worksheet with information - becoming annoying and inefficient. Is there a better worksheet specific sub to put this under?
Hopefully, this makes sense on what I am trying to achieve. Thank you community for all the help and assistance!
- RD