terminate after else statement

freezefiz

Board Regular
Joined
May 21, 2008
Messages
101
Hey everyone..

how do you terminate the esle-statement after the msgbox has appeared??

Apparently the msgbox appeared multiple times.

If you need the sample of the data table pls let me know.

Thanks Thanks.

Code:
If CStr(Worksheets("db").Cells(intRow, 1).Value) = Sheets("GrandTotal").Range("b1").Value Then 'if date value match...
                
                proID = Worksheets("db").Cells(intRow, 6).Value
                pro = Worksheets("db").Cells(intRow, 7).Value
                uom = Worksheets("db").Cells(intRow, 9).Value
                qty = Worksheets("db").Cells(intRow, 8).Value
         
                qty = "=SUMPRODUCT(--(db!R2C1:R[" & nDb & "]C1=R1C2),--(db!R2C6:R[" & nDb & "]C6=RC1),--(db!R2C7:R[" & nDb & "]C7=RC2),--(db!R2C9:R[" & nDb & "]C9=RC3),db!R2C8:R[" & nDb & "]C8)"
                                          'Date'                             'prodID'                         'prod'                            'uom'                          'qty'
                Range("b2").Formula = "=IF(ISNUMBER(B1),TEXT(WEEKDAY(B1),""dddd""),""Day?"")"
                Set rProd = Sheets("GrandTotal").Range("a" & Columns.count).End(xlUp)
                rProd.Offset(1, 0).Resize(, 2) = Array(proID, pro)
                             
                Set rUOM = Sheets("GrandTotal").Range("c" & Columns.count).End(xlUp)
                rUOM.Offset(1, 0).Resize(, 2) = Array(uom, qty)
             
              Else
             MsgBox "no such date!", vbExclamation, "No orders"
---------->[B][COLOR=red]TERMINATE HERE[/COLOR][/B]
 
                                         
            End If
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,961
Office Version
  1. 365
Platform
  1. Windows
If you want it to exit the macro at this point:

Code:
Exit Sub
 
Upvote 0

freezefiz

Board Regular
Joined
May 21, 2008
Messages
101
Hey guyz thanks for the reply...

i'm sorry but i think i left out some parts of my codes.

Code:
[B]Do While[/B] Worksheets("db").Cells(intRow, 2).Value <> ""
            If CStr(Worksheets("db").Cells(intRow, 1).Value) = Sheets("GrandTotal").Range("b1").Value Then 'if date value match...
                
                proID = Worksheets("db").Cells(intRow, 6).Value
                pro = Worksheets("db").Cells(intRow, 7).Value
                uom = Worksheets("db").Cells(intRow, 9).Value
                qty = Worksheets("db").Cells(intRow, 8).Value
         
                qty = "=SUMPRODUCT(--(db!R2C1:R[" & nDb & "]C1=R1C2),--(db!R2C6:R[" & nDb & "]C6=RC1),--(db!R2C7:R[" & nDb & "]C7=RC2),--(db!R2C9:R[" & nDb & "]C9=RC3),db!R2C8:R[" & nDb & "]C8)"
                                          'Date'                             'prodID'                         'prod'                            'uom'                          'qty'
                Range("b2").Formula = "=IF(ISNUMBER(B1),TEXT(WEEKDAY(B1),""dddd""),""Day?"")"
                Set rProd = Sheets("GrandTotal").Range("a" & Columns.count).End(xlUp)
                rProd.Offset(1, 0).Resize(, 2) = Array(proID, pro)
                             
                Set rUOM = Sheets("GrandTotal").Range("c" & Columns.count).End(xlUp)
                rUOM.Offset(1, 0).Resize(, 2) = Array(uom, qty)
             
             [B] Else
             MsgBox "no such date!", vbExclamation, "No orders"
[COLOR=red]----->only wants the msgbox to appear once. and continue with program[/COLOR][/B]
                                                      
            End If 'end of if date value match...
        
            intRow = intRow + 1
        [B]Loop[/B]

Thanks.
 
Upvote 0

Forum statistics

Threads
1,190,919
Messages
5,983,588
Members
439,852
Latest member
balasat

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
Top