Excel VBA, hiding columns based on certain conditions

FaisalAlTawil

New Member
Joined
Mar 23, 2023
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hey all

I want to make a macro that hides columns if any cell under has a formula, and then copies the same hided column and paste it in new column as hard numbers. in that way I can ensure that all formulas are reserved while all unhide data are as hard coded.


thanks in advance!
Faisal
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi Faisal,

It is possible but what about the structure of your file ? So if column B as one cell with a formula, then column B will be hidden and copied in column H (assuming your data extends to column G) ? Below macro will copy the entire sheet and clear all formulas which might be an even easier method

VBA Code:
Sub test()

ActiveSheet.Copy , ActiveSheet
ActiveSheet.UsedRange = ActiveSheet.UsedRange.Value

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top