+ Reply to Thread
Results 1 to 2 of 2

VBA code to read a value in a spreadsheet and act accordingly

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    roswell
    MS-Off Ver
    O365
    Posts
    95

    VBA code to read a value in a spreadsheet and act accordingly

    Hi,
    Been trying for an hour. Goal is to have a user form (done) and the code will enter the data into cells when clicked (done). Now I want to place some logic so that if the value of some calculated cells (not cells where data is entered)after the data is entered and the sheet calculates is out of bounds, I want the form to either still be displayed or have the form redisplay retaining the other data. I tried IF stement as follows

    B71 is an optional field so there are 2 calculations i am checking depending if B71 is >0 or not

    If Sheets("Bob Calculator").Range("b71") = 0 Then
    If Sheets("Bob Calculator").Range("b91") = " Pipe Length is Not OK" Then
    Msg = "Pipe Diameter is too small for the length of pipe - Please reenter a larger Pipe"
    Else
    If Sheets("Bob Calculator").Range("b71") < 0 Then
    Msg = "Invalid Boiler MBH entered- Please reenter"
    Else
    If Sheets("Bob Calculator").Range("b98") = " Pipe Length is Not OK" Then
    Msg = "Pipe Diameter is too small for the length of pipe - Please reenter a larger Pipe"
    End If

    I placed it in the same code where the data is added and the code seems to freeze
    Last edited by delaneybob; 06-07-2012 at 10:25 PM.

  2. #2
    Registered User
    Join Date
    02-06-2012
    Location
    roswell
    MS-Off Ver
    O365
    Posts
    95

    Re: VBA code to read a value in a spreadsheet and act accordingly

    I have it working now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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