试图在Excel单元格中隐藏文本 [英] Trying to hide text in an excel cell

查看:49
本文介绍了试图在Excel单元格中隐藏文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对调查结果进行测试.对于每个问题的列标题,它们分别是IMP1,IMP2等.我要执行的操作是将问题放置在此单元格中,以便单击标题时可以看到问题,但是从文件的概述中可以看到问题用户只能看到的是IMP1.

I am looking at running test on survey results. For the column headers for each question they are IMP1, IMP2, etc. What I want to be able to do is place the question in this cell so that when you click on the header you can see the question but from the overview of the file all the user can see is IMP1.

不确定该措辞是否有意义,但是基本上,当您单击一个单元格时,我想要公式部分中的文本.如果未选中该单元格,则应仅显示IMP1.

Not sure if that wording makes sense but basically I want the text in the formula section when you click on a cell. When the cell isn't selected it should just show IMP1.

推荐答案

这专门用于单个单元格 A1 ,但可以扩展为处理 A列中的所有单元格.首先在单元格中输入以下内容:

This is specifically for the single cell A1, but can be expanded to process all the cells in column A. First enter this in the cell:

IMP1What is the meaning of life ??

,然后将以下 Event宏放入工作表代码区域:

and then place the following Event Macro in the worksheet code area:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim A1 As Range

    Set A1 = Range("A1")
    l = Len(A1.Text)

    If Intersect(A1, ActiveCell) Is Nothing Then
        A1.Characters(Start:=1, Length:=l).Font.ColorIndex = 1
        A1.Characters(Start:=5, Length:=l).Font.ColorIndex = 2
    Else
        A1.Characters(Start:=1, Length:=l).Font.ColorIndex = 1
        A1.Characters(Start:=1, Length:=4).Font.ColorIndex = 2
    End If
End Sub

如果单击 A1 ,您将看到:

,如果您单击该单元格,则会看到:

and if you click off the cell, you will see:

由于它是工作表代码,因此非常易于安装和自动使用:

Because it is worksheet code, it is very easy to install and automatic to use:

  1. 右键单击Excel窗口底部附近的标签名称
  2. 选择查看代码-这将打开一个VBE窗口
  3. 将内容粘贴并关闭VBE窗口

如果您有任何疑问,请先在试用工作表上尝试一下.

If you have any concerns, first try it on a trial worksheet.

如果保存工作簿,则宏将随其一起保存.如果要在2003年以后使用Excel版本,则必须保存该文件为.xlsm而不是.xlsx

If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx

要删除宏,请执行以下操作:

To remove the macro:

  1. 如上所述调出VBE窗口
  2. 清除代码
  3. 关闭VBE窗口

要全面了解有关宏的更多信息,请参见:

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

http://msdn.microsoft.com/en-us/library/ee814735(v = office.14).aspx

要了解有关事件宏(工作表代码)的更多信息,请参阅:

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

必须启用宏才能使其正常工作!

这篇关于试图在Excel单元格中隐藏文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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