I have this code and I would like to use Vlookup as a criteria to shorten my Macro as well as to make it transferable to other files. However, I do not know how I can use Vlookup to make "Nov 15" or "Dec 15" as a criteria to hide the previous columns as well as the columns after showing a full year of data. Please help me Thanks!
November 15
Sheets("Charts_wkg").Select
Columns("D:X").Select
Selection.Columns.Ungroup
Columns("D:Y").Select
Selection.Columns.Group
Columns("D:Y").Hidden = True
Columns("AL:BB").Select
Selection.Columns.Ungroup
Columns("AM:BB").Select
Selection.Columns.Group
Columns("AM:BB").Hidden = True
Columns("Z:AL").Hidden = False
December 15
Sheets("Charts_wkg").Select
Columns("D:X").Select
Selection.Columns.Ungroup
Columns("D:Z").Select
Selection.Columns.Group
Columns("D:Z").Hidden = True
Columns("AM:BB").Select
Selection.Columns.Ungroup
Columns("AN:BB").Select
Selection.Columns.Group
Columns("AN:BB").Hidden = True
Columns("AA:AM").Hidden = False
January 16
Sheets("Charts_wkg").Select
Columns("D:X").Select
Selection.Columns.Ungroup
Columns("D:AA").Select
Selection.Columns.Group
Columns("D:AA").Hidden = True
Columns("AN:BB").Select
Selection.Columns.Ungroup
Columns("AO:BB").Select
Selection.Columns.Group
Columns("AO:BB").Hidden = True
Columns("AB:AN").Hidden = False
You can used the following code to locate the current month and once located once located can use the cell as reference for hidding and unhiding the cells using offset
Dim SearchText As String
SearchText = InputBox("Enter the Text in column which needs to be unhidden")
Rows("11:11").Select
Selection.Find(What:="" & SearchText & "", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Select
' ActiveCell.EntireColumn.select
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.