|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Imports Microsoft.Office.Tools.Ribbon
Imports Excel = Microsoft.Office.Interop.Excel
Public Class 第一个功能区Ribbon
Private Myfind As String
'定义要查找的内容变量
Private DQHang As Integer
'定义当前光标选中的行变量
Private DQLie As Integer
'定义当前光标选中的列变量
Private UseHang As Integer
'已经使用的区域的行数
Private UseLie As Integer
'已经使用的区域的列数
Private Sub 第一个功能区Ribbon_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
End Sub
Private Sub Button年级单科名次_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button年级单科名次.Click
ThisWorkbook.Worksheets("Sheet1").Activate() '激活工作表
UseHang = ActiveCell.SpecialCells(xlLastCell).Row
'UseHang =激活工作表的已用行数
UseLie = ActiveCell.SpecialCells(xlLastCell).Column
'UseLie = 激活工作表的已用列数
Myfind = "语文"
Call ChaZhao()
End Sub
Private Sub ChaZhao()
Dim Rng As Excel.Range
With ActiveSheet.Range(Cells(1, 1), Cells(UseHang, UseLie))
Rng = .Find(What:=Myfind, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto(Rng, True)
MsgBox(Rng.Cells.Row & "hang" & Rng.Cells.Column)
Else
MsgBox("没有找到该单元格!""")
End If
End With
End Sub
'下面
'部分在该程序中暂时没用到
'显示第一个任务窗格
Private Sub ToggleButton1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton1.Click
Globals.ThisAddIn.TaskLGM1.Visible = TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked
End Sub
'显示第二个任务窗格
Private Sub ToggleButton2_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles ToggleButton2.Click
Globals.ThisAddIn.TaskLGM2.Visible = TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked
End Sub
End Class |
|