ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if a column is hidden or visible in VBA (https://www.excelbanter.com/excel-programming/394885-check-if-column-hidden-visible-vba.html)

Stephen C

Check if a column is hidden or visible in VBA
 
I have some VBA code which copies part of a spreadsheet to a new workbook,
when i copy it i need to be able to check if a column has been hidden or not,
if it has been hidden then i need to hide the same column on the new sheet.

e.g. If column F is hidden on the current sheet then hide column F on the
new workbook.

I am using Excel 2000.

JW[_2_]

Check if a column is hidden or visible in VBA
 
Can you please post up the code as it currently is?

Stephen C wrote:
I have some VBA code which copies part of a spreadsheet to a new workbook,
when i copy it i need to be able to check if a column has been hidden or not,
if it has been hidden then i need to hide the same column on the new sheet.

e.g. If column F is hidden on the current sheet then hide column F on the
new workbook.

I am using Excel 2000.



Anony

Check if a column is hidden or visible in VBA
 
Just tweak this until it fits your specific needs:

Sub HiddenColumns()
Dim i As Long

For i = 1 To 256
Workbooks("Workbook1").Sheets("Sheet1").Columns(i) .Hidden =
Workbooks("Workbook1").Sheets("Sheet1").Columns(i) .Hidden
Next i

End Sub

------
Cheers,
Anony


"Stephen C" wrote:

I have some VBA code which copies part of a spreadsheet to a new workbook,
when i copy it i need to be able to check if a column has been hidden or not,
if it has been hidden then i need to hide the same column on the new sheet.

e.g. If column F is hidden on the current sheet then hide column F on the
new workbook.

I am using Excel 2000.


Stephen C

Check if a column is hidden or visible in VBA
 
Just a little tweak and it works fine.

Thank you

"Anony" wrote:

Just tweak this until it fits your specific needs:

Sub HiddenColumns()
Dim i As Long

For i = 1 To 256
Workbooks("Workbook1").Sheets("Sheet1").Columns(i) .Hidden =
Workbooks("Workbook1").Sheets("Sheet1").Columns(i) .Hidden
Next i

End Sub

------
Cheers,
Anony


"Stephen C" wrote:

I have some VBA code which copies part of a spreadsheet to a new workbook,
when i copy it i need to be able to check if a column has been hidden or not,
if it has been hidden then i need to hide the same column on the new sheet.

e.g. If column F is hidden on the current sheet then hide column F on the
new workbook.

I am using Excel 2000.



All times are GMT +1. The time now is 05:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com