URGENT Checkbox Code Needed

Sweetmusic1

New Member
Joined
Dec 1, 2014
Messages
6
I created Checkbox Code that when checked, it brings me to the related worksheet and expands the rows. I want it to ONLY expand the row in the related worksheet and not actually bring me there. What do I have wrong? I am new to VBA so I can't seem to see the error. Sub ANCHORLINK()
ActiveWindow.SmallScroll Down:=-3
Sheets("Transition Worksheet").Select
If ROWS(14).ShowDetail = True Then
ROWS(14).ShowDetail = False
Else

If ROWS(14).ShowDetail = False Then
ROWS(14).ShowDetail = True
End If
End If
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try...

Code:
[COLOR=darkblue]Sub[/COLOR] ANCHORLINK()
    [COLOR=darkblue]With[/COLOR] Sheets("Transition Worksheet")
        [COLOR=darkblue]If[/COLOR] .Rows(14).ShowDetail = [COLOR=darkblue]True[/COLOR] [COLOR=darkblue]Then[/COLOR]
            .Rows(14).ShowDetail = [COLOR=darkblue]False[/COLOR]
        [COLOR=darkblue]ElseIf[/COLOR] .Rows(14).ShowDetail = [COLOR=darkblue]False[/COLOR] [COLOR=darkblue]Then[/COLOR]
            .Rows(14).ShowDetail = [COLOR=darkblue]True[/COLOR]
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

However, it can be re-written as follows...

Code:
[COLOR=darkblue]Sub[/COLOR] ANCHORLINK()
    [COLOR=darkblue]With[/COLOR] Sheets("Transition Worksheet")
        .Rows(14).ShowDetail = [COLOR=darkblue]Not[/COLOR] .Rows(14).ShowDetail
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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