Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
Dim hoja As Excel.Worksheet = Globals.ThisAddIn.Application.Workbooks(1).Worksheets(1)
Dim col_son As Integer
Dim col_desde As Integer
Dim col_hasta As Integer
Dim col_resul As Integer
Dim fila, col, fila_fin, col_fin, fil_cont, col_cont As Long
Dim interr As Integer
col_son = EditBox1.Text
col_desde = EditBox2.Text
col_hasta = EditBox3.Text
col_resul = EditBox4.Text
fila = 1
col = 1
fila_fin = fila
col_fin = col
MsgBox("Tiene que estar ordenada la tabla ")
While (Len(hoja.Cells(fila_fin, col_son).value) <> 0)
'MsgBox(hoja.Cells(fila, col_son).value)
fila_fin = fila_fin + 1
End While
While (Len(hoja.Cells(fila, col_fin).value) <> 0)
'MsgBox(hoja.Cells(fila, col_son).value)
col_fin = col_fin + 1
End While
col_fin = col_fin - 1
fila_fin = fila_fin - 1
MsgBox("Nombre del sondaje : " & hoja.Cells(fila, col_son).value & Chr(13) & "Campo Desde : " & hoja.Cells(fila, col_desde).value & Chr(13) & "Campo Hasta : " & hoja.Cells(fila, col_hasta).value)
interr = MsgBox("Evaluara hasta la fila : " & fila_fin & " y columna : " & col_fin, MsgBoxStyle.OkCancel, "Informacion")
If (interr = 1) Then
hoja.Cells(fila, col_resul).Value = "Overlaps"
hoja.Cells(fila, col_resul + 1).Value = "From igual To"
hoja.Cells(fila, col_resul + 2).Value = "From mayor To"
fil_cont = fila + 1
While (fil_cont <= fila_fin)
If (hoja.Cells(fil_cont + 1, col_son).Value = hoja.Cells(fil_cont, col_son).Value) _
And (hoja.Cells(fil_cont + 1, col_desde).Value < hoja.Cells(fil_cont, col_hasta).Value) Then
hoja.Cells(fil_cont, col_resul).Value = "Overlaps"
hoja.Cells(fil_cont + 1, col_resul).Value = "Overlaps"
End If
If (hoja.Cells(fil_cont, col_desde).Value = hoja.Cells(fil_cont, col_hasta).Value) Then
hoja.Cells(fil_cont, col_resul + 1).Value = "From igual To"
End If
If (hoja.Cells(fil_cont, col_desde).Value > hoja.Cells(fil_cont, col_hasta).Value) Then
hoja.Cells(fil_cont, col_resul + 2).Value = "From > To"
End If
fil_cont = fil_cont + 1
End While
End If
MsgBox("Proceso Terminado")
End Sub