How to initiate code

guestuser

New Member
Joined
Mar 9, 2010
Messages
29
When I have edited links in a document, I want to activate a code. But it doesn’t activate.. what am I doing wrong??<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
It works if I go into the cell (F2), and then push enter.. (But I don't want the users to have to do that..)
<o:p></o:p>
<o:p>There might be many mistakes in this code.. I am a newbie..</o:p>
<o:p> </o:p>
<o:p></o:p>
Option Explicit<o:p></o:p>
<o:p> </o:p>
Private Sub Workbook_Open()<o:p></o:p>
'<o:p></o:p>
' Editlinks<o:p></o:p>
'<o:p></o:p>
Application.SendKeys ("%a")<o:p></o:p>
Application.SendKeys ("k")<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
:eek: SO FAR IT WORKS FINE... <o:p></o:p>
<o:p> </o:p>
Private Sub Worksheet_Change(ByVal target As Range)<o:p></o:p>
<o:p> </o:p>
Dim cScreens As Object<o:p></o:p>
Dim cOptional_S_F As Object<o:p></o:p>
Dim yes As Boolean<o:p></o:p>
<o:p></o:p>
If Range("cScreens") = ("yes") Then Rows("34:51").Hidden = False Else Rows("34:51").Hidden = True<o:p></o:p>
If Range("cOptional_S_F") = ("yes") Then Rows("24:33").Hidden = False Else Rows("24:33").Hidden = True<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
:eek: This last part doesn’t start on its own.. I think I need to initiate it somehow..?<o:p></o:p>
 
I am sorry for going on about this, but it's really not working.. it just keeps showing the rows, even though the cell does not say 'yes' after I update the links :confused:
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Then either the code is in the wrong place, or you have disabled events. Open the VBEditor (Alt+f11) then press Ctrl+G to open the Immediate Window and type in:
Code:
Application.Enableevents = True
and then press Enter. Then try updating the links again.
 
Upvote 0
now I got it to work, but only with my old one.

Private Sub Worksheet_Calculate()
On Error Resume Next
Application.EnableEvents = False
If Range("cScreens") = ("yes") Then Rows("34:51").Hidden = False Else Rows("34:51").Hidden = True
If Range("cOptional_S_F") = ("yes") Then Rows("24:33").Hidden = False Else Rows("24:33").Hidden = True
Application.EnableEvents = True
End Sub

with the me.range, it kept the rows hidden when 'yes' was in the cell, and showed the rows when the cell was empty..

Thank you for all your help :)
 
Upvote 0
That doesn't really make sense since in a worksheet code module Range is the same as Me.Range, but as long as it's working, who cares. :)
 
Upvote 0

Forum statistics

Threads
1,215,883
Messages
6,127,545
Members
449,385
Latest member
KMGLarson

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