注册 登录
编程论坛 VB6论坛

求大神帮编一个,利用VB创建界面,实现对excel文件数据的赛选

num911 发布于 2017-03-16 16:38, 1184 次点击
EXCEL的数据量不大,大概2百行左右,列8列,就一个工作薄。

比较着急,请大神快快帮忙啊,多谢!
2 回复
#2
ZHRXJR2017-03-17 10:55
你筛选,怎么筛选,具体操作是什么?不知道怎么回答你?
2百行左右,小意思,但没有条件怎么说?
#3
wds12017-03-18 22:02
Private Sub command1_Click()
  Dim xlsApp As Excel.Application 'EXECL类型文件
  Dim xlsBook As Excel.Workbook  'execl工作表
  Dim xlsSheet As Excel.Worksheet 'execl sheet
  Dim row_tail  '行总数
  Dim col_total  '列总数
 
  commondialog1.Filter = "数据文件(*.xls)|*.xls"'需要引用文件控件,如果不用文件对话方式打开,可以直接给出execl文件名
  commondialog1.Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
  commondialog1.ShowOpen '打开execl文件作为输入文件
  If commondialog1.FileName <> "" Then
    Set xlsApp = CreateObject("Excel.Application")             '打开EXECL类型文件
    Set xlsBook = xlsApp.Workbooks.Open(commondialog1.FileName) '打开已经存在的EXCEL工件簿文件
    Set xlSheet = xlsBook.Worksheets(1)                         '设置活动工作表
    row_tail = xlsSheet.UsedRange.Rows.Count
    col_tail = xlsSheet.UsedRange.Columns.Count
    For i = 1 To row_tail
    For j = 1 To col_tail
      If xlSheet.Cells(i, j) = "判断条件" Then
        '具体的执行
        Exit For
      End If
    Next j
    Next i
    xlsBook.Close (True) '关闭工作簿
    xlsApp.Quit '结束EXCEL对象
  End If
End Sub
1