Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Adding user defined range in macro

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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Adding user defined range in macro

Sub Clear_Empty_Columns()
' Clear_Empty_Columns Macro
' Macro recorded 5/19/2009 by Jacky Del Hoyo
'
Dim varRange As Range
Set varRange = Application.InputBox("Select range", Type:=8)

For Each cell In varRange.Cells
If (cell) = 0 Then
cell.Columns.EntireColumn.Hidden = True
Else
cell.Columns.EntireColumn.Hidden = False
End If
Next cell

End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Jacky D." wrote:

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined Range caveman.savant Excel Programming 3 February 13th 09 02:59 PM
Adding help to a user defined function Diarmuid Excel Programming 2 January 6th 08 12:17 PM
User defined function - adding names chillihawk Excel Programming 4 June 1st 06 07:54 AM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
Adding a pop-up help to a user-defined function james s shoenfelt Excel Programming 1 September 26th 03 03:51 AM


All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"