Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VBA small code error?

Hi everone,

Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):

If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If

Thanks,
Jo

  #2   Report Post  
Posted to microsoft.public.excel.programming
bac bac is offline
external usenet poster
 
Posts: 76
Default VBA small code error?

Did you notice Zone5 is not in quotes/

"Jo" wrote:

Hi everone,

Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):

If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If

Thanks,
Jo


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBA small code error?

For starters put Option Explicit at the top of all your modules.
There is no such thing as Cell.
You can do Range("Zone4")

RBS

"Jo" wrote in message
oups.com...
Hi everone,

Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):

If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If

Thanks,
Jo


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VBA small code error?

On Aug 10, 12:00 pm, BAC wrote:
Did you notice Zone5 is not in quotes/



"Jo" wrote:
Hi everone,


Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):


If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If


Thanks,
Jo- Hide quoted text -


- Show quoted text -


I have it like this now but when I run the macro I get an error:
Method 'Cells' of object '_global' failed!

If Zone5 = 0 Then
Cells("Zone5").Select
Selection.EntireRow.Hidden = True
End If
If Zone4 = 0 Then
Cells("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 = 0 Then
Cells("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 = 0 Then
Cells("Zone2").Select
Selection.EntireRow.Hidden = True
End If

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VBA small code error?

On Aug 10, 12:10 pm, Jo wrote:
On Aug 10, 12:00 pm, BAC wrote:





Did you notice Zone5 is not in quotes/


"Jo" wrote:
Hi everone,


Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):


If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If


Thanks,
Jo- Hide quoted text -


- Show quoted text -


I have it like this now but when I run the macro I get an error:
Method 'Cells' of object '_global' failed!

If Zone5 = 0 Then
Cells("Zone5").Select
Selection.EntireRow.Hidden = True
End If
If Zone4 = 0 Then
Cells("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 = 0 Then
Cells("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 = 0 Then
Cells("Zone2").Select
Selection.EntireRow.Hidden = True
End If- Hide quoted text -

- Show quoted text -


It is working now with Range instead of Cells. However, I am saying
"If Zone4=0....etc." and while I have Zone4=5, it is hiding that row!?

How come?

Thanks,
Jo



  #6   Report Post  
Posted to microsoft.public.excel.programming
bac bac is offline
external usenet poster
 
Posts: 76
Default VBA small code error?

Is it possible one of the other zones, that is 0, is on the same row?

"Jo" wrote:

On Aug 10, 12:10 pm, Jo wrote:
On Aug 10, 12:00 pm, BAC wrote:





Did you notice Zone5 is not in quotes/


"Jo" wrote:
Hi everone,


Could someone please tell me what is wrong with this small piece of
code, note that Zone5 is cell name ( I am getting error in the 2nd
row):


If Zone5 0 Then
Cell(Zone5).Select
Selection.EntireRow.Hidden = True
End If
If Zone4 0 Then
Cell("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 0 Then
Cell("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 0 Then
Cell("Zone2").Select
Selection.EntireRow.Hidden = True
End If


Thanks,
Jo- Hide quoted text -


- Show quoted text -


I have it like this now but when I run the macro I get an error:
Method 'Cells' of object '_global' failed!

If Zone5 = 0 Then
Cells("Zone5").Select
Selection.EntireRow.Hidden = True
End If
If Zone4 = 0 Then
Cells("Zone4").Select
Selection.EntireRow.Hidden = True
End If
If Zone3 = 0 Then
Cells("Zone3").Select
Selection.EntireRow.Hidden = True
End If
If Zone2 = 0 Then
Cells("Zone2").Select
Selection.EntireRow.Hidden = True
End If- Hide quoted text -

- Show quoted text -


It is working now with Range instead of Cells. However, I am saying
"If Zone4=0....etc." and while I have Zone4=5, it is hiding that row!?

How come?

Thanks,
Jo


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
Just A Small Code FARAZ QURESHI Excel Discussion (Misc queries) 1 December 24th 08 12:52 PM
VBA Print Code Is Too Small Minitman[_4_] Excel Programming 2 January 18th 06 06:24 PM
Will pay someone to write small event code for me!! [email protected] Excel Discussion (Misc queries) 2 February 26th 05 02:03 PM
Will pay someone to write small Excel code for me [email protected] Excel Worksheet Functions 2 February 26th 05 12:25 PM
Will pay someone to write small Excel code for me [email protected] Links and Linking in Excel 1 February 26th 05 01:40 AM


All times are GMT +1. The time now is 11:35 PM.

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"