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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing values across sheets.

Status
Not open for further replies.

schnabs

Technical User
Jan 21, 2009
50
0
0
Hello,
I have a workbook with two sheets. I am trying to use VB to make sure the totals on each are equal, as they should be. This is my code thus far.

Private Sub Compare_Click() Handles compare.Click
Dim oxl As Microsoft.Office.Interop.Excel.Application
Dim oxlbook As Microsoft.Office.Interop.Excel.Workbook
Dim path As String

path = Dir("Z:\2009 Combined Delinquencies\" & "0" & Month(Now) & " " & MonthName(Month(Now)) & "\")

oxl = New Microsoft.Office.Interop.Excel.Application
oxl.DisplayAlerts = False
oxl.Visible = True
Do While path <> ""
oxlbook = oxl.Workbooks.Open("Z:\2009 Combined Delinquencies\" & "0" & Month(Now) & " " & MonthName(Month(Now)) & "\" + path)

If oxlbook.Worksheets(2).Range("A65536").End("-4162").value = oxlbook.Worksheets(1).cells("B:B").large.value Then

Else
MsgBox("Fix")
End If


Loop


End Sub

My problem is coming from obtaining the second value, where I tried using large. There is text beneath the value, which prevents me from using the endxlup, but it is the only number in column B. I thought if I use the max, or large, function, it would work. Any ideas or thought??

Thanks.
 
The best help I can give is to do it in Excel VBA. If it will work in Excel then it will work when you are using an Excel object in VB.net.

Two things I can say. If your range is a single cell do not use End. You cannot use Cells("B[red]1[/red]:B[red]1[/red]") as Cells requires (Row, Column). You are trying to pass it a range and that should not work.

I don't understand what you are trying to do so I can't offer more help.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top