ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Posting---If function problem again (https://www.excelbanter.com/excel-discussion-misc-queries/219529-re-posting-if-function-problem-again.html)

chrisnsmith

Posting---If function problem again
 

I'm new at this. What is MsgBox and where will it be displayed?
"Sheeloo" wrote:

Previous post was not complete...
I meant put the statements after My_Procedure in a SUB and then call that SUB.
I tested the following macro after entering 2/13/2009 in B13 and it showed
the message "If is OK"

Try it
Sub Test()
If Weekday(Date, vbMonday) = 5 And Cells(13, 2) = Date - 3 Then GoTo
My_Procedure
End If
End Sub

My_Procedu
Msgbox "IF is OK"
'With Sheets("Cus Futures")
' .Range(" H9:I50").Copy Range("D9:E50")
' .Range("F9:I50").ClearContents
Range("M2") = Date
'End With
End Sub


"Sheeloo" wrote:

Use call My_Procedure instead of Go to My_Procedure

"chrisnsmith" wrote:

Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.

The responses I received from my previous post asked that I post my code.

This is the If...EndIf code.

Private Sub Workbook_Open()
If Weekday(Date, vbMonday) = 2 And Cells(13, 2) = Date - 3 Then GoTo
My_Procedure
End If
End Sub


My_Procedu
With Sheets("Cus Futures")
.Range(" H9:I50").Copy Range("D9:E50")
.Range("F9:I50").ClearContents
Range("M2") = Date
End With

'
'
With Sheets("House Futures")
.Range(" H9:I50").Copy Range("D9:E50")
.Range("F9:I50").ClearContents
Range("M2") = Date
End With


This is the If...ElseIf code.

Private Sub Workbook_Open()
If Weekday(Date, vbMonday) = 2 And Cells(1, 1) = Date - 3 Then GoTo
My_Procedure
ElseIf Weekday(Date, vbMonday) = 2 And Cells(1, 1) = Date - 1 Then GoTo
My_Procedure
End If
End Sub


My_Procedu
With Sheets("Cus Futures")
.Range(" H9:I50").Copy Range("D9:E50")
.Range("F9:I50").ClearContents
Range("M2") = Date
End With

'
'
With Sheets("House Futures")
.Range(" H9:I50").Copy Range("D9:E50")
.Range("F9:I50").ClearContents
Range("M2") = Date
End With



All times are GMT +1. The time now is 12:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com