Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if row two is blank in an excel file

Status
Not open for further replies.

daillest319

Programmer
Apr 9, 2012
29
US
i not sure how to do this but im trying to have my vbs script check if row 2 is empty in my Arrow.xls file. if its empty i want it to email from a template with the file and if there nothing in row 2 i want it to email from a different template.

so i need to check row two and email using two different otf files depending if the xls file has data in row 2
 
hi,
if its empty i want it to email from a template with the file and if there nothing in row 2 i want it to email from a different template.
So what's the difference?
Code:
With YourExelObject
  if 
   .Counta(.YourWorkbookObject.YourSheetObject.Rows(2)) > 0 then
    ' have data in row 2
  else
    ' have no data in row 2
  end if
End with


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
i have two diffrent email to send if i recieve data and if i dont. im actually fine with the email part. just need check row two for data. im confused ion what im doing wrote this is what i have. i would like it to check this workbook and if there data i would like it to start formatting otherwise send an email.


Code:
Set xlApp = Createobject("Excel.Application")
xlApp.Visible = False
xlApp.Screenupdating = False
xlApp.Workbooks.Open "C:\sample\test.xls.xls"
WScript.Sleep 1000

With xlApp.Workbooks("test.xls").ActiveSheet

.Range("A:AG").Font.Name = "Times New Roman"
.Range("A:AG").Font.Size = "10"
.Columns.AutoFit

End With

xlApp.ActiveWorkbook.Close True
xlApp.Quit
Set xlApp = Nothing
 
Code:
    Set xlapp = CreateObject("Excel.Application")
    xlapp.Visible = False
    xlapp.ScreenUpdating = False
    With xlapp.Workbooks.Open("C:\sample\test.xls.xls")
        WScript.Sleep 1000
        
        With .Sheets("[b]Use An Actual Sheet Name[/b]")
            With .UsedRange
                .Font.Name = "Times New Roman"
                .Font.Size = "10"
                .Columns.AutoFit
            End With
            
            If xlapp.CountA(.Rows(2)) > 0 Then
              ' have data in row 2
            Else
              ' have no data in row 2
            End If
        End With
        
        .Close True
        
    End With
    
    xlapp.Quit
    Set xlapp = Nothing

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top