• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Conditional msgbox|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Conditional msgbox|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosConditional msgbox
sp_PrintTopic sp_TopicIcon
Conditional msgbox
Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
1
March 26, 2021 - 2:58 am
sp_Permalink sp_Print

I am creating a calendar for scheduling, I am trying to have a warning message pop up if you try and schedule a day the employee has asked for off. The issue I was having was the data validation wasn't recognizing the macro so I decided to try and write it into the macro. I got it to work when looking at an absolute reference, now I'm having the worst time trying to figure out an index and match solution to match the date with the employee name. I have googled and watched videos and my brain hurts! The macro is in Module 4 attached to the first command button in the attached worksheet. 

A couple of other mentions:

- The schedule will be entered into the Calendar tab.

- The days off will be entered into the Employees tab.

I'm still very new to macros, any help is greatly appreciated!

sp_AnswersTopicSeeAnswer See Answer
Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
March 26, 2021 - 6:15 am
sp_Permalink sp_Print

I am really struggling to see what the Macro is trying to do?

If i click the top button it checks E5 and then populates times in the activecell

Are you saying that instead of checking E5 you want to check the person and date of the active cell?

 

Somthing like this?

Dim DateX As Long
Dim EmName As String

EmName = Cells(ActiveCell.Row, 3)
DateX = Cells(10, ActiveCell.Column).Text

Worksheets("Employees").Cells(Worksheets("Employees").Range("a:a").Find(what:=EmName, LookIn:=xlValues, lookat:=xlWhole).Row, _
Worksheets("Employees").Range("4:4").Find(what:=DateX, LookIn:=xlValues, lookat:=xlPart).Column) = "X"

sp_AnswersTopicAnswer
Answers Post
Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
3
March 27, 2021 - 12:05 am
sp_Permalink sp_Print

That's it! Thank you so much! You're my superstar!!

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
4
March 30, 2021 - 1:55 am
sp_Permalink sp_Print

I am having more issues! I'm trying to google but I'm not finding the answer that will suffice. I am also trying to have the worksheet check the number of hours worked and alert the supervisor if an employee is being scheduled for more than 40 hours. The current code I have is this:

Dim Week1 As Long
Dim Week2 As Long
Dim Week3 As Long
Dim Week4 As Long
Dim Week5 As Long
Dim Week6 As Long

On Error Resume Next

Week1 = Cells(ActiveCell.Row, 38)
Week2 = Cells(ActiveCell.Row, 39)
Week3 = Cells(ActiveCell.Row, 42)
Week4 = Cells(ActiveCell.Row, 43)
Week5 = Cells(ActiveCell.Row, 44)
Week6 = Cells(ActiveCell.Row, 45)

If Week1 > 1.5 Then
MsgBox "Employee is scheduled for overtime, would you like to continue?", vbYesNo + vbExclamation + vbDefaultButton2

End If
End Sub

I'm having issues with how the code is looking at the information in the cell, if I use the decimal for the time everything comes up as >, if I use the actual ie ">40" nothing does. Attached is the current workbook. Module 4 is my "Test Module" to get my code working before I touch any of the actual working pieces of code in my workbook.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
5
March 30, 2021 - 9:57 pm
sp_Permalink sp_Print

A Long is a Long Integer, so always a whole number. I suspect you want Double.

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
6
March 31, 2021 - 12:08 am
sp_Permalink sp_Print

Unfortunately that doesn't seem to be the problem, or maybe at least not the only problem...?

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOfflineSmall Offline
7
March 31, 2021 - 12:25 am
sp_Permalink sp_Print

I finally got it to work! Thank you so much! I had tweak some more, but I think the big issue was using the wrong declaration, thank you!!

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Andy Kirby, Scott Miller, Roy Lutke, Jeff Krueger, Kylara Papenfuss, Ivica Cvetkovski
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.