macro to hide unhide cells

bluepenink

Well-known Member
Joined
Dec 21, 2010
Messages
585
Hello

i used a offset function in my graph but for some reason its not working. unfortunately i cant post a sample but i was wondering if some one can show me can help me with inserting a macro so rows can hide

i.e. my data lies A19:D25.
my offset that i have defined is as follows:
=OFFSET(Reference!$A$19,0,0,MAX(1,COUNTA(Reference!$A$19:$A$25)-COUNT(Reference!$A$19:$A$25)),1)

so technically it should only show active entries on the graph but its not.

but is it possible for a macro or something to show only cells in my specified range to be unhidden/hide?...ive been at this for a day+ so itd b very grateful.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You aren't able to hide a single cell but only rows/columns.
I.E.
Code:
Rows("4:4").EntireRow.Hidden = True
 
Upvote 0
hello

should i insert that into a module or that specific worksheet itself? also...is that going to hide any rows that dont have data in my specificed range? thxs
 
Upvote 0
If you want it works only a determinate worksheet, in worksheet, else, in a module.
Code:
' The following code deletes blank rows from the active worksheet.
 
Dim Counter
Dim i As Integer
 
Sub HIDERow()
 
' Input box to determine the total number of rows in the worksheet.
Counter = InputBox("Enter the total number of rows to process")
Activecell.Select
' Loops through the desired number of rows.
For i = 1 To Counter
    ' Checks to see if the active cell is blank.
    If ActiveCell = "" Then
        Selection.EntireRow.Hidden = True
        ' Decrements count each time a row is deleted. This ensures
        ' that the macro will not run past the last row.
        Counter = Counter - 1
    Else
        ' Selects the next cell.
        ActiveCell.Offset(1, 0).Select
    End If
 
Next i
 
End Sub
from: http://support.microsoft.com/kb/110759/en but i modified code to hide rows
 
Upvote 0
Hello

Is it possible for the macro to run the macro automatically?

i.e. my data is on range A19:D27

my range if the state has 4 cities will be 19:D25
otherwise itll be a19:D27, which is fine, but i would like the rows to remain hidden if there is no data in row A24-27....im grateful to your help!
 
Upvote 0
Depend on...
Yuo could associate its to a event of Workbook or Worksheet...
You make a research in the Help on Line.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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