| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1827 人关注过本帖
标题:菜鸟求解EXCEL代码
只看楼主 加入收藏
不言子
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2022-2-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
菜鸟求解EXCEL代码
图片附件: 游客没有浏览图片的权限,请 登录注册

以下是网页找到的excel切片器跟随滚动条定位代码
求解怎么才能作用于工作簿中的某一个工作表
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Dim ShF As Shape
    Dim ShM As Shape
    Dim ShN As Shape
    Dim ShO As Shape
    'specify a slicer
    Application.ScreenUpdating = False
    Set ShF = ActiveSheet.Shapes("类别 2")
    Set ShM = ActiveSheet.Shapes("科目 2")
    Set ShN = ActiveSheet.Shapes("部属 1")
    Set ShO = ActiveSheet.Shapes("经办人")
    'change position of the slicer
    With Windows(1).VisibleRange.Cells(1, 1)
        ShF.Top = .Top + 30
        ShF.Left = .Left + 773
        ShM.Top = .Top + 30
        ShM.Left = .Left + 850
        ShN.Top = .Top + 30
        ShN.Left = .Left + 928
        ShO.Top = .Top + 30
        ShO.Left = .Left + 1006
    End With
    Application.ScreenUpdating = True
End Sub
搜索更多相关主题的帖子: Dim EXCEL Set Left Top 
2022-02-09 01:34
约定的童话
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:56
帖 子:246
专家分:1442
注 册:2021-8-1
收藏
得分:10 
上传附件看下
2022-02-09 07:16
wen3523
Rank: 2
等 级:论坛游民
威 望:1
帖 子:6
专家分:19
注 册:2022-2-8
收藏
得分:10 
Private Sub Command1_Click()

' Option1(0).Value = True
 Sum单元 = 0
 
Set Newxls_基数 = CreateObject("excel.application")         '创建Excel应用程序并打开之
     Newxls_基数.Workbooks.Open (App.Path & "\项目基本数据.xls")   '打开EXCEL工作簿
   
   For i = 0 To 15
      Newxls_基数.Worksheets(i + 1).Select '选择工作表
      Newxls_基数.Rows("1:5000").Clear        '清除表格内容
   Next i

 Dim MyStr$
 MyStr = "项目名称='" & Str项目名 & "'"

 For i = 0 To 15
  If i = 0 Then SQL = "select * from 田地平整表 where " & MyStr
  If i = 1 Then SQL = "select * from 道路基数表 where " & MyStr
  If i = 2 Then SQL = "select * from 涵表 where " & MyStr
  If i = 3 Then SQL = "select * from 桥基数表 where " & MyStr
  If i = 4 Then SQL = "select * from 水源基数表 where " & MyStr
  If i = 5 Then SQL = "select * from 输水基数表 where " & MyStr
  
  If i = 6 Then SQL = "select * from 泵站基数表 where " & MyStr
  If i = 7 Then SQL = "select * from 岸坡基数表 where " & MyStr
  If i = 8 Then SQL = "select * from 坡面基数表 where " & MyStr
  If i = 9 Then SQL = "select * from 造林基数表 where " & MyStr
  If i = 10 Then SQL = "select * from 其它基数表 where " & MyStr
  
  If i = 11 Then SQL = "select * from 单元序号表 where " & MyStr & " order by 单ID "
  If i = 12 Then SQL = "select * from 分部序号表 where " & MyStr & " order by 分ID "
  If i = 13 Then SQL = "select * from 单位序号表 where " & MyStr & " order by 位ID "
  If i = 14 Then SQL = "select * from 隐蔽序号表 where " & MyStr & " order by 隐ID "
  If i = 15 Then SQL = "select * from 坐标序号表 where " & MyStr & " order by 坐标ID "
  
      Adodc1(i).CommandType = adCmdUnknown
      Adodc1(i).RecordSource = SQL
      Adodc1(i).Refresh
      Set DataGrid1.DataSource = Adodc1(i)
    If Adodc1(i).Recordset.RecordCount > 0 Then OutToExcel单元基础数 DataGrid1, i      '这地方不能有“(”,有则显示出错!!!
Next i

Newxls_基数.Visible = True   '设置EXCEL可见

'  Newxls_基数.Visible = True   '设置EXCEL可见

End Sub
2022-02-09 11:54
kedian1968
Rank: 2
等 级:论坛游民
帖 子:15
专家分:15
注 册:2022-2-15
收藏
得分:0 
我太菜了 看不懂題目
2022-03-11 15:47
蝈曲曲
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2022-3-22
收藏
得分:0 
请问楼主,表格要实现什么功能?我自己经常用VBA解决工作中的问题
2022-03-23 21:35
快速回复:菜鸟求解EXCEL代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016767 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved