Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ====================================== 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Eric,
If wkbk Is Nothing And myCell.Offset(0, 2).Value < Date Then -- Regards, OssieMac "Eric" wrote: 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 ====================================== 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to add condition to coding? | Excel Programming | |||
lookup with multiple condition, but one condition to satisfy is en | Excel Worksheet Functions | |||
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? | Excel Programming | |||
Implant macro coding into ASP coding | Excel Programming | |||
I need 4 condition for condition formatting | Excel Programming |