exaccounting
New Member
- Joined
- Dec 1, 2015
- Messages
- 4
<tbody>
[TD="class: votecell"][/TD]
[TD="class: postcell"] I want to display/show columns based on cell values or button commands – VBA Eg : I am trying to compare monthly sales values for the period Jan to Dec via VBA Code, I want to show only two columns (range of columns) for two months which I am comparing among 12 months. So if I want to compare March and April, I would select March In cell A2 and April cell B2, and macros/code should show only range of cells based on these two cell values (A2= March and B2= April ) which would be March sale ranges, and April Sales ranges (column headings) and so on. I have tried to write the code as follows but I am not able to show two ranges of cells together …..
[/TD]
</tbody>
Code:
<code>Sub RevHideColumnsHR1()
Select Case Range("D4").Value
Case "January"
Range("A:B,H:AN").Select
Selection.EntireColumn.Hidden = True
End select
End sub</code>
Once it shows correct range of columns, I also want to give simple difference formula for visible columns cells only (sale values for each customer in Mar and April) the variance range of columns would be fixed but only considering visible columns/cell values for calculation purpose…