ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HIDING CELLS AND COLUMNS (https://www.excelbanter.com/excel-programming/386479-hiding-cells-columns.html)

chris morr

HIDING CELLS AND COLUMNS
 
I have a spreadsheet with three columns A, B, and C. If there is no
value in column A, then I want columns B AND C hidden. Conversley, if
a cell in column A is not blank, then do not hide columns B and C. If or
when any cell in column A does have a value typed into it, then columns B and
C are, or become, unhidden.

ALSO,

I have three columns in another spreadsheet, again A, B, and C. If the cell
in column A1 is blank, I would like the cells in column B1 and C1 to say N/A,
or maybe be shaded grey, I havent decided yet. If cell A1 is not blank, then
dont do anything or change B1 and C1. If or when A1 does have a value typed
in it, then B1 and C1 revert to normal, allowing values will be typed in by
the user.

Any specific help for someone who is not very well versed in visual basic?
And, if so, where would you go about attaching the code?

Thanks alot, chris M

Barb Reinhardt

HIDING CELLS AND COLUMNS
 
YOu can't have B and C hidden in one row and unhidden in the next. Try this:


Sub testing()
Dim myRange As Range
Dim r As Range
Dim myrange2
Dim myhiddenrange As Range
Set myRange = ActiveSheet.Range("A1:A10")
For Each r In myRange
Set myhiddenrange = r.Offset(0, 1).Resize(1, 2)
If IsEmpty(r) Then
myhiddenrange.Font.ColorIndex = 1
Else
myhiddenrange.Font.ColorIndex = 2
End If
Next r
End Sub

"chris morr" wrote:

I have a spreadsheet with three columns A, B, and C. If there is no
value in column A, then I want columns B AND C hidden. Conversley, if
a cell in column A is not blank, then do not hide columns B and C. If or
when any cell in column A does have a value typed into it, then columns B and
C are, or become, unhidden.

ALSO,

I have three columns in another spreadsheet, again A, B, and C. If the cell
in column A1 is blank, I would like the cells in column B1 and C1 to say N/A,
or maybe be shaded grey, I havent decided yet. If cell A1 is not blank, then
dont do anything or change B1 and C1. If or when A1 does have a value typed
in it, then B1 and C1 revert to normal, allowing values will be typed in by
the user.

Any specific help for someone who is not very well versed in visual basic?
And, if so, where would you go about attaching the code?

Thanks alot, chris M



All times are GMT +1. The time now is 01:14 AM.

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