在Excel中,可以使用超链接来运行vba宏吗? [英] In Excel, can I use a hyperlink to run vba macro?

查看:787
本文介绍了在Excel中,可以使用超链接来运行vba宏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多行数据的电子表格。我想要能够使用该行中的数据单击运行宏的单元格。由于行数将始终在变化,我虽然每行的超链接可能是最好的方法。

  ROW MeterID Lat Long ReadX ReadY ReadZ CoeffA CoeffB CoeffC 
2 10f62gs 34.1 33.3 102.2 231.3 382.2 4.34 22.1 0.002
3 83gs72g 34.4 31.4 109.2 213.1 372.1 2.23 12.7 0.023
4 43gS128 33.3 32.2 118.8 138.7 241.8 1.94 5.08 0.107

有没有办法通过点击超链接来运行vba宏,并且能够知道点击超链接的单元格

解决方案

这将为您工作

  Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBoxRow& ActiveCell.Row& 点击
End Sub


I have a spreadsheet that has many rows of data. I would like to be able to click on a cell that will run a macro using the data from that row. Since the number of rows will always be changing, I though a hyperlink for each row might be the best way.

   ROW MeterID   Lat    Long   ReadX  ReadY  ReadZ   CoeffA  CoeffB  CoeffC
   2   10f62gs   34.1   33.3   102.2  231.3  382.2   4.34    22.1    0.002
   3   83gs72g   34.4   31.4   109.2  213.1  372.1   2.23    12.7    0.023
   4   43gS128   33.3   32.2   118.8  138.7  241.8   1.94    5.08    0.107

Is there a way to run a vba macro from clicking on a hyperlink and being able to know the row of the cell that clicked on the hyperlink?

解决方案

This will work for you

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
        MsgBox "Row " & ActiveCell.Row & " is clicked"
End Sub

这篇关于在Excel中,可以使用超链接来运行vba宏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆