Thread
:
Adding user defined range in macro
View Single Post
#
3
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Adding user defined range in macro
Should do it
Sub hidecolumnsinrow()
mycell = InputBox("Enter starting cell ie: a20")
mr = Range(mycell).Row
mc = Range(mycell).Column
lc = Cells(mr, Columns.Count).End(xlToLeft).Column
For i = mc To lc
If Cells(mr, i) = 0 Then Columns(i).Hidden = True
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Jacky D." wrote in message
...
I'd like to know if I can add an inputbox to the following macro so I can
define what row to test the If statement against. Right now, I am going
into
the macro and changing the range (ie from "A31:CL31" to "A50:CL50"), but
that's un ugly solution. I am not a programmer, and am usually pretty good
at
finding code and modifying to suit my needs, but this is a bit beyond my
scope.
Macro to hide rows if column is zero:
Sub Clear_Empty_Columns()
'
' Clear_Empty_Columns Macro
' Macro recorded 5/19/2009 by Jacky Del Hoyo
'
'
For Each cell In Range("A31:CL31").Cells
If (cell) = 0 Then
cell.Columns.EntireColumn.Hidden = True
Else
cell.Columns.EntireColumn.Hidden = False
End If
Next cell
End Sub
Thanks,
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett