End IF

tlindeman

Active Member
Joined
Jun 29, 2005
Messages
313
I am not sure how to do this, I need the following VBA code to execute without ending each section. For example, I need it to look at date for 5/30 and then 6/30 and then 7/31. If any of those conditions are not satisfied, then end . Please let me know if that is not clear. Thank YOu Tony

If Date >= CDate("05/30/2011") Then
Sheets("Class III Inputs").Select
Range("H18:J18").Select
Selection.ClearContents
Sheets("INPUTS").Select
If Date >= CDate("06/30/2011") Then
Sheets("Class III Inputs").Select
Range("H19:J19").Select
Selection.ClearContents
Sheets("INPUTS").Select
If Date >= CDate("07/31/2011") Then
Sheets("Class III Inputs").Select
Range("H20:J20").Select
Selection.ClearContents
Sheets("INPUTS").Select
End If
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Possibly

Code:
If Date >= CDate("07/31/2011") Then
    Sheets("Class III Inputs").Range("H20:J20").ClearContents
    Sheets("INPUTS").Select
ElseIf Date >= CDate("06/30/2011") Then
    Sheets("Class III Inputs").Range("H19:J19").ClearContents
    Sheets("INPUTS").Select
ElseIf Date >= CDate("05/30/2011") Then
    Sheets("Class III Inputs").Range("H18:J18").ClearContents
    Sheets("INPUTS").Select
End If
 
Upvote 0
You requirements are a little muddled, so not sure which of these. But one of these two ought to be what your looking for. Also, please use CODE tags and proper indentation when posting code. With a modest snippet like this it's not a major felony. But if your code had been much longer I would have skipped your post due to lack of code tags and indenting.
Code:
    Sheets("INPUTS").Select
    If Date >= CDate("05/30/2011") Then
        Sheets("Class III Inputs").Range("H18:J18").ClearContents
    End If
    If Date >= CDate("06/30/2011") Then
        Sheets("Class III Inputs").Range("H19:J19").ClearContents
    End If
    If Date >= CDate("07/31/2011") Then
        Sheets("Class III Inputs").Range("H20:J20").ClearContents
    End If
Code:
    Sheets("INPUTS").Select
    If Date >= CDate("05/30/2011") Then
        Sheets("Class III Inputs").Range("H18:J18").ClearContents
    ElseIf Date >= CDate("06/30/2011") Then
        Sheets("Class III Inputs").Range("H19:J19").ClearContents
    ElseIf Date >= CDate("07/31/2011") Then
        Sheets("Class III Inputs").Range("H20:J20").ClearContents
    End If
 
Upvote 0
Sorry I will figure out how to use code tags and use in the future. THank you both for your help. Both of these will work.

Tony
 
Upvote 0
Peter - how did you disable the tags in order to make your last post? Something obvious that I'm overlooking?
 
Upvote 0
Hi Greg :)

Type

[*noparse]

without the *

then the code tags then

[*/noparse]

without the *

I owe MrKowz for that tip.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

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