在范围Excel中获取上次使用的列

时间:2015-05-20 15:38:53

标签: c# excel vba excel-vba

有人可以帮我处理代码示例以执行以下操作

  1. 获取第2行
  2. 返回第2行中与当前日期匹配的列(行中的某些单元格具有其他日期没有的日期)
  3. 获取返回列的范围
  4. 这是开始

    ' Create new Application.
    Dim excel As Excel.Application = New Excel.Application
    
    ' Open Excel spreadsheet.
    Dim w As Excel.Workbook = excel.Workbooks.Open("Y:\rjcp\testFile.xslx")
    
    'THIS IS WHERE I AM HAVING AN ISSUE
    Dim r As Excel.Range = sheet.Range("A1", excel.Range("A1").End(Microsoft.Office.Interop.Excel.XlDirection.xlToRight))
    For Each aCell In r
    

1 个答案:

答案 0 :(得分:0)

for i = 1 to activesheet.usedrange.columns.count
if cells(2,i).value = format(date,"dd/mm/yy") ' input your desired date format here
msgbox cells(2,i).column
end if