I have been using MS Access VBA to create the Excel object and perform data analysis from within Access. I have been able to do this successfully when looking at a value from a row & column. I am now attempting to compare a data point in a column to another data point in another column, both using the same row. I am trying to figure out the types of loops to use and whether to use Worksheet or Range. This example I am attempting to use the Worksheet, but it is failing
In this particular situation I am trying to compare Column (E) and Column (K) and using the same Row (starting at row 5 and ending at used rows), so if Column E = "RECOCOM" and
Column (K) = Null, then simply put a jagged RED border around the cell in Column (K). Any pointers would be appreciated!!
Dim objexcel_app As Object
Dim xlsExcel_wkbook As Object
Dim xlsExcel_sheet As Object
Dim xlsExcel_range As Object
Dim Z As Long
Dim i As Integer
Set objexcel_app = CreateObject("Excel.Application")
objexcel_app.Visible = False
Set xlsExcel_wkbook = objexcel_app.Workbooks.Open("C:\Deal\New_NMTC_TLR_Note.xls")
Set xlsExcel_sheet = xlsExcel_wkbook.sheets("New_NMTC_TLR_Note")
Z = xlsExcel_sheet.UsedRange.rows(xlsExcel_sheet.UsedRange.rows.Count).row
For i = 5 To Z
If xlsExcel_sheet.cells(i, 5).Value = "RECOCOM" And xlsExcel_sheet.cells(i, 11).Value = vbNullString Then
xlsExcel_sheet.cells(i, 11).Borders(9).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(8).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(7).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(10).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(9).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(8).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(7).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(10).Color = RGB(255, 0, 0)
Else
End If
Next i
In this particular situation I am trying to compare Column (E) and Column (K) and using the same Row (starting at row 5 and ending at used rows), so if Column E = "RECOCOM" and
Column (K) = Null, then simply put a jagged RED border around the cell in Column (K). Any pointers would be appreciated!!
Dim objexcel_app As Object
Dim xlsExcel_wkbook As Object
Dim xlsExcel_sheet As Object
Dim xlsExcel_range As Object
Dim Z As Long
Dim i As Integer
Set objexcel_app = CreateObject("Excel.Application")
objexcel_app.Visible = False
Set xlsExcel_wkbook = objexcel_app.Workbooks.Open("C:\Deal\New_NMTC_TLR_Note.xls")
Set xlsExcel_sheet = xlsExcel_wkbook.sheets("New_NMTC_TLR_Note")
Z = xlsExcel_sheet.UsedRange.rows(xlsExcel_sheet.UsedRange.rows.Count).row
For i = 5 To Z
If xlsExcel_sheet.cells(i, 5).Value = "RECOCOM" And xlsExcel_sheet.cells(i, 11).Value = vbNullString Then
xlsExcel_sheet.cells(i, 11).Borders(9).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(8).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(7).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(10).LineStyle = 4
xlsExcel_sheet.cells(i, 11).Borders(9).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(8).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(7).Color = RGB(255, 0, 0)
xlsExcel_sheet.cells(i, 11).Borders(10).Color = RGB(255, 0, 0)
Else
End If
Next i