A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro works Macro does not work



 
 
Thread Tools Display Modes
  #1  
Old March 24th, 2008, 12:28 PM posted to microsoft.public.excel.misc
Wanna Learn
external usenet poster
 
Posts: 340
Default Macro works Macro does not work

Hello I have two macros, separately they work but when I combined them into
one macro it does not work. Below is the macro combined. Thank you for help
Private Sub Worksheet_Change(ByVal Target As Range)
'With Target
'If .Address "$B$28" Then Exit Sub
'If .Value = " Agreement" Then
' Rows(32).Hidden = False
'Rows(33).Hidden = True
' Rows(39).Hidden = True
'ElseIf .Value = "Master Agreement" Then
' Rows(32).Hidden = True
' Rows(33).Hidden = False

'ElseIf (Range("S4") = "Yes") Then

'Sheets("Discount
").Range("90:90,93:93,95:95,129:129,159:159,161:16 1,162:162,164:164,165:165,166:166,168:168,171:171, 306:306,308:308,343:343,345:345,350:350").EntireRo w.Hidden = True
'Else

'Sheets("Discount
").Range("90:90,93:93,95:95,129:129,159:159,161:16 1,162:162,164:164,165:165,166:166,168:168,171:171, 306:306,308:308,343:343,345:345,350:350").EntireRo w.Hidden = False

'End If

'End With


'End Sub

  #2  
Old March 24th, 2008, 12:37 PM posted to microsoft.public.excel.misc
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default Macro works Macro does not work

1) are you sure you DON'T have all the apostrophes in the beginning of
each line? my advise would be to remove them

2) you miss "End If" statement after
'ElseIf .Value = "Master Agreement" Then
' Rows(32).Hidden = True
' Rows(33).Hidden = False

at least this is what i have noticed
  #3  
Old March 24th, 2008, 12:51 PM posted to microsoft.public.excel.misc
Mike H
external usenet poster
 
Posts: 8,419
Default Macro works Macro does not work

good point i removed them and never mentioned it

Mike

"Jarek Kujawa" wrote:

1) are you sure you DON'T have all the apostrophes in the beginning of
each line? my advise would be to remove them

2) you miss "End If" statement after
'ElseIf .Value = "Master Agreement" Then
' Rows(32).Hidden = True
' Rows(33).Hidden = False

at least this is what i have noticed

  #4  
Old March 24th, 2008, 12:51 PM posted to microsoft.public.excel.misc
Mike H
external usenet poster
 
Posts: 8,419
Default Macro works Macro does not work

Hi,

One typo theres a space in front of Agreement which I guess you
don't want but apart from that as long as cell B28 changes
then it works. What it won't do is run if S4 Changes. To make it run if B28
or S4 change then try this

If Intersect(Target, Range("B28,S4")) Is Nothing Then Exit Sub

Mike

"Wanna Learn" wrote:

Hello I have two macros, separately they work but when I combined them into
one macro it does not work. Below is the macro combined. Thank you for help
Private Sub Worksheet_Change(ByVal Target As Range)
'With Target
'If .Address "$B$28" Then Exit Sub
'If .Value = " Agreement" Then
' Rows(32).Hidden = False
'Rows(33).Hidden = True
' Rows(39).Hidden = True
'ElseIf .Value = "Master Agreement" Then
' Rows(32).Hidden = True
' Rows(33).Hidden = False

'ElseIf (Range("S4") = "Yes") Then

'Sheets("Discount
").Range("90:90,93:93,95:95,129:129,159:159,161:16 1,162:162,164:164,165:165,166:166,168:168,171:171, 306:306,308:308,343:343,345:345,350:350").EntireRo w.Hidden = True
'Else

'Sheets("Discount
").Range("90:90,93:93,95:95,129:129,159:159,161:16 1,162:162,164:164,165:165,166:166,168:168,171:171, 306:306,308:308,343:343,345:345,350:350").EntireRo w.Hidden = False

'End If

'End With


'End Sub

  #5  
Old March 24th, 2008, 12:51 PM posted to microsoft.public.excel.misc
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default Macro works Macro does not work

sorry, forget about 2)
you have got Exit Sub in yr 1st "if"
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:54 PM.


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