LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Locate cell name using variable and looping


Hi everybody

I have named some cells in a worksheet in the following way: Skjul1,
Skjul2, Skjul3... Skjul69, Skjul70.

Now I would like to make a vba script that locates each cell and checks
the value of the cell. If the value = 0, the entire row should be
hidden.

I thought that I could make a loop like the following:

Private Sub Skjul()
Dim i As Long
i = 0
Do Until i = 75
If Sheets("spec").Range("Skjul" & i).Value = "0" Then
Sheets("spec").Range("Skjul" & i).EntireRow.Hidden =
True
Else
Sheets("spec").Range("Skjul" & i).EntireRow.Hidden =
False
End If
On Error GoTo 0
i = i + 1
Loop Until i = 75
End Sub

... but it doesn't work! I get the error: "Run-time error '1004':
Application-defined or object-defined error".

Can anyone help me? I would really appreciate the effort!


--
Thomas Olesen
------------------------------------------------------------------------
Thomas Olesen's Profile: http://www.excelforum.com/member.php...o&userid=28025
View this thread: http://www.excelforum.com/showthread...hreadid=475313

 
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
Using INDEX() to Locate Variable Data Shadowboy Excel Discussion (Misc queries) 4 August 21st 06 02:17 PM
Looping and String Variable Mourinho Excel Programming 4 October 28th 04 10:02 PM
Looping to create Variable Names? Jill E Excel Programming 3 August 10th 04 12:17 AM
Increment a variable while looping ibeetb Excel Programming 2 September 25th 03 07:15 PM
locate max value in variable range Alan Beban[_3_] Excel Programming 0 August 11th 03 05:00 AM


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

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

About Us

"It's about Microsoft Excel"