基于用户输入的动态隐藏列

时间:2017-12-20 20:09:05

标签: excel-vba vba excel

我有一张工作表,其中列出了第14行的年份,其中各种值都低于这些年份。我希望有一个用户输入单元格,他们可以输入他们想要查看的年数,同时隐藏其余列。我知道这个代码必须简单,但我似乎很难绕过如何实际编码。我尝试了以下方法:

Sub HideCol()

Range("F14").Select

yearSelect = Range("J8").Value

numrows = Selection.Rows.Count
numCols = Selection.Columns.Count

Selection.Resize(numrows + 0, numCols + yearSelect).Select

Selection.EntireColumnHidden = True


End Sub

我真的认为我是在调整大小的反转之后,这意味着我隐藏了所选区域而不是隐藏其余列。提前谢谢你,

1 个答案:

答案 0 :(得分:1)

如果我理解你的问题,请在F列之前将年份输入单元格更改为另一列,否则会冒隐藏输入单元格的风险:)

然后将此代码放在数据所在的工作表模块中。根据数据需要对代码进行范围调整。

01 mkdir -p /home/deploy/list/releases/20171220202012/assets_manif…
✔ 01 influencerlist.io 0.048s
  WARN  Rails assets manifest file not found.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host influencerlist.io: Rails assets manifest file not found.


Caused by:
Capistrano::FileNotFound: Rails assets manifest file not found.

Tasks: TOP => deploy:assets:backup_manifest
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host influencerlist.io: Rails assets manifest file not found.