Custom Data Validation - How to call a VBA Subroutine

jimfernish

New Member
Joined
May 29, 2018
Messages
1
Overview:
Create a worksheet that allows employees to track their hours worked each day. Before allowing time entries, verify the user has entered their Name, Number and a Pay period date. After verifying the (3) fields have been filled, validate the time entry and round to the nearest 15 minute interval. Allow the user to enter;

  • 8a convert this cell value to 0800, display the entry as 8:00am
  • 812a convert this cell value to 0815, display the entry as 8:15am
  • 12p convert this cell value to 1200, display the entry as 12:00pm
  • 105p convert this cell value to 1300, display the entry as 1:00pm
  • 455p convert this cell value to 1700, display the entry as 5:00pm
  • 1700 complete the other validations, display the entry as 5:00pm

Goal:
After the user enters data into a cell, use Data Validation to call a Visual Basic subroutine. My thoughts are to use the ActiveCell.Value;

  • Verify Name, Number & Date cells are filled
  • Use ActiveCell.Value and verify time entry is a true time entry and manipulate the cell value as needed.
  • If any of the (3) cells are not filled, return an error box with the missing item message.
  • If the time entry is not valid, return an error box with “invalid time entry” message
  • Return the updated ActiveCell.Value with the manipulated value to the active cell in the worksheet, if time is valid.

Questions:

  • Is it possible to create a function that call the subroutine, validates and returns the manipulated cell contents?
  • Are there any examples of the Functions & Subroutines?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,216,116
Messages
6,128,929
Members
449,479
Latest member
nana abanyin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top