+ Reply to Thread
Results 1 to 4 of 4

Problem with a macro generating a msgbox instruction

  1. #1
    Registered User
    Join Date
    11-18-2014
    Location
    Hulll, England
    MS-Off Ver
    2007
    Posts
    5

    Problem with a macro generating a msgbox instruction

    Hello everyone. I am a novice when it comes to VBA but my problem is this:
    I have a sheet which generates a calculated time in column J. This comes from a function of two times automatically generated from two other columns. What I'm trying to do is to generate an error message (or warning message) if the calculated time in column Jexceeds 30 minutes. I have written the following macro but it doesnt work. Can anyone help?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column("J").Value > 0.042361111 Then
    MsgBox "Downtime needs recording"
    End If
    End Sub

    I think there may be a problem with the time as I've entered it as a decimal but other than that I dont know how to fix it

    Hope someone can help please.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem with a macro generating a msgbox instruction

    please use code tags around your code in future

    how is your function triggered? are your changing cells data or are you refreshing data?

    Please Login or Register  to view this content.
    maybe something like this is what your after?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    11-18-2014
    Location
    Hulll, England
    MS-Off Ver
    2007
    Posts
    5

    Re: Problem with a macro generating a msgbox instruction

    Thanks for the reply. Just to let you know what I'm doing. For example my worksheet:

    Start time: 13:00
    Finish time: 13:45

    So when the finish time is great than 30 minutes from the start time I'd like an error message.

    So I tried your code, I tagged it onto the end of the existing macro I have in place and I'm getting the error message now "Ambiguous name detected: Worksheet_Change" .....it says to change the name or how do I make this a separate macro in VB?

    I hope this makes sense. Help gratefully received.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Problem with a macro generating a msgbox instruction

    you cant have two worksheet_change codes at the same time
    that's probably what the error message is for

    save a copy of your file and replace your code with mine or vice versa then try again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ignoring an instruction on a macro loop if folder already exists
    By Macro_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2014, 09:31 AM
  2. [SOLVED] Problem with VBA Editor uses lower case on some lines (ex. msgbox instead of MsgBox)
    By stubbsj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 06:59 PM
  3. problem with generating new worksheet in macro and transferring values
    By benniboi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2012, 07:42 AM
  4. Problem with generating Combinations (Myrna Larson macro)
    By Excelstudent12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2012, 04:28 AM
  5. Finding an instruction in a macro
    By Raiby in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2007, 09:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1