Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to add condition to coding?

Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today] Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default How to add condition to coding?

If wkbk Is Nothing And myCell.Offset(0, 2).Value < DateSerial(Year(Now),
Month(Now), Day(Now)) Then

HIH


U¿ytkownik "Eric" napisa³ w wiadomo¶ci
...
Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today]
Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to add condition to coding?

Thank you very much for suggestions
I get an error, which is related to missing some variable setting or With's
variable.
Do you have any suggestions on how to fix it?
Thank you very much for any suggestions
Eric

"Jarek Kujawa" wrote:

If wkbk Is Nothing And myCell.Offset(0, 2).Value < DateSerial(Year(Now),
Month(Now), Day(Now)) Then

HIH


U¿ytkownik "Eric" napisa³ w wiadomo¶ci
...
Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today]
Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to add condition to coding?

Please paste your code so as to recreate the issue..

If this post helps click Yes
--------------
Jacob Skaria


"Eric" wrote:

Thank you very much for suggestions
I get an error, which is related to missing some variable setting or With's
variable.
Do you have any suggestions on how to fix it?
Thank you very much for any suggestions
Eric

"Jarek Kujawa" wrote:

If wkbk Is Nothing And myCell.Offset(0, 2).Value < DateSerial(Year(Now),
Month(Now), Day(Now)) Then

HIH


U¿ytkownik "Eric" napisa³ w wiadomo¶ci
...
Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today]
Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to add condition to coding?

Please see the following coding
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Option Explicit
Sub Updating_Lists()

Dim myRng As Range
Dim myCell As Range
Dim wkbk As Workbook

With Worksheets("Table").Range("C3")
.NumberFormat = "hh:mm AM/PM"
.Value = Now
End With

With Worksheets("Lists")
'still starting in row 2!
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
Set wkbk = Nothing
On Error Resume Next
On Error GoTo 0
myCell.Offset(0, 1).Value = ""

Next myCell

For Each myCell In myRng.Cells
Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks.Open(Filename:=myCell.Value, UpdateLinks:=3)
On Error GoTo 0

<<< Add the condition here

If wkbk Is Nothing Then

<<< Add the condition here

myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"
With myCell.Offset(0, 2)
.NumberFormat = "mm/dd/yyyy"
.Value = Date
End With
With myCell.Offset(0, 3)
.NumberFormat = "hh:mm:ss"
.Value = Time
End With

End If
Next myCell

With Worksheets("Table").Range("E3")
.NumberFormat = "hh:mm AM/PM"
.Value = Now
End With

'better to include an extension
Workbooks("Update Up.xls").Close savechanges:=True

End Sub


"Jacob Skaria" wrote:

Please paste your code so as to recreate the issue..

If this post helps click Yes
--------------
Jacob Skaria


"Eric" wrote:

Thank you very much for suggestions
I get an error, which is related to missing some variable setting or With's
variable.
Do you have any suggestions on how to fix it?
Thank you very much for any suggestions
Eric

"Jarek Kujawa" wrote:

If wkbk Is Nothing And myCell.Offset(0, 2).Value < DateSerial(Year(Now),
Month(Now), Day(Now)) Then

HIH


U¿ytkownik "Eric" napisa³ w wiadomo¶ci
...
Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today]
Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to add condition to coding?

Dear Eric

If wkbk Is Nothing And CDate(myCell.Offset(0, 2).value) < Date Then


If this post helps click Yes
--------------
Jacob Skaria


"Eric" wrote:

Please see the following coding
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Option Explicit
Sub Updating_Lists()

Dim myRng As Range
Dim myCell As Range
Dim wkbk As Workbook

With Worksheets("Table").Range("C3")
.NumberFormat = "hh:mm AM/PM"
.Value = Now
End With

With Worksheets("Lists")
'still starting in row 2!
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
Set wkbk = Nothing
On Error Resume Next
On Error GoTo 0
myCell.Offset(0, 1).Value = ""

Next myCell

For Each myCell In myRng.Cells
Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks.Open(Filename:=myCell.Value, UpdateLinks:=3)
On Error GoTo 0

<<< Add the condition here

If wkbk Is Nothing Then

<<< Add the condition here

myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"
With myCell.Offset(0, 2)
.NumberFormat = "mm/dd/yyyy"
.Value = Date
End With
With myCell.Offset(0, 3)
.NumberFormat = "hh:mm:ss"
.Value = Time
End With

End If
Next myCell

With Worksheets("Table").Range("E3")
.NumberFormat = "hh:mm AM/PM"
.Value = Now
End With

'better to include an extension
Workbooks("Update Up.xls").Close savechanges:=True

End Sub


"Jacob Skaria" wrote:

Please paste your code so as to recreate the issue..

If this post helps click Yes
--------------
Jacob Skaria


"Eric" wrote:

Thank you very much for suggestions
I get an error, which is related to missing some variable setting or With's
variable.
Do you have any suggestions on how to fix it?
Thank you very much for any suggestions
Eric

"Jarek Kujawa" wrote:

If wkbk Is Nothing And myCell.Offset(0, 2).Value < DateSerial(Year(Now),
Month(Now), Day(Now)) Then

HIH


U¿ytkownik "Eric" napisa³ w wiadomo¶ci
...
Does anyone have any suggestions on how to add condition into coding?

I would like to add the condition, please see []
If wkbk Is Nothing [and myCell.Offset(0, 2).Value is not equal today]
Then
Thanks in advance for any suggestions
Eric

======================================
Original Coding
======================================

If wkbk Is Nothing Then
myCell.Offset(0, 1).Value = "Failed to open!"
Else
wkbk.Close savechanges:=True
myCell.Offset(0, 1).Value = "ok"




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
Condition 1 overules condition 2? Bultgren Excel Worksheet Functions 2 January 20th 06 12:29 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
I need 4 condition for condition formatting SeeKY Excel Programming 2 June 7th 05 09:41 AM


All times are GMT +1. The time now is 09:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"