k31th less WHY; more WOT Site Developer 29,187 Member For: 16y 9m 23d Gender: Male Location: Melbourne Posted 30/09/13 04:00 AM Share Posted 30/09/13 04:00 AM I'm trying to set up a macro enabled sheet which can take outputs from a program I use.. Anyway since the program is reporting different trials of data.. But it always reports all the series in a particular project.. What I want to be able to do is be able to hide rows as required by changing the value of a cell right up the top.. between 1 - 10 so to speak.. I can order the output so the preferred options output as say 1-4 and less preferred 5-10. I've attempted to embed a code in the sheet code.. But it doesn't seem to want to work.. When I run the debugger it doesn't make it past the first line.. Aiming for something that if cell B1 = 1 it hides rows 42-150 = 2 it hides rows 53-150 and so on.. I think the code is right.. I just don't know how to get it to constantly refresh on the cell.. The only way to do that will be programatically through a macro or code (the hiding function). Then you need an "scanning" function that notices when you change cell B1, so it runs automatically some code in the background that chooses the relevant cases (1,2,3 etc) and runs the "hide" code (or separate macro) as necessary for the value that's just been entered into the cell.if that makes any sense Link to comment Share on other sites More sharing options...
Never had any say Panda I <3 Floods Silver Donating Members 11,198 Member For: 13y 6m 1d Gender: Male Location: South West QLD Posted 30/09/13 04:10 AM Share Posted 30/09/13 04:10 AM Sub Test1(ByVal Target As Range)Dim Stubs As IntegerStubs = Range("$B$1").ValueIf Stubs > 10 Then Exit SubEnd IfIf Stubs = "1" Then Range("42:150").EntireRow.Hidden = TrueElseIf Stubs = "2" Then Range("53:150").EntireRow.Hidden = TrueElseIf Stubs = "3" Then Range("64:150").EntireRow.Hidden = TrueElseIf Stubs = "4" Then Range("75:150").EntireRow.Hidden = TrueElseIf Stubs = "5" Then Range("86:150").EntireRow.Hidden = TrueElseIf Stubs = "6" Then Range("97:150").EntireRow.Hidden = TrueElseIf Stubs = "7" Then Range("108:150").EntireRow.Hidden = TrueElseIf Stubs = "8" Then Range("119:150").EntireRow.Hidden = TrueElseIf Stubs = "9" Then Range("130:150").EntireRow.Hidden = TrueElse End IfEnd SubIf this helps this is my current code. I just don't know how to jig it to to the auto scan thing.. Link to comment Share on other sites More sharing options...
k31th less WHY; more WOT Site Developer 29,187 Member For: 16y 9m 23d Gender: Male Location: Melbourne Posted 30/09/13 04:47 AM Share Posted 30/09/13 04:47 AM You'll need a method in here with something along these lines, to trigger the macro you have here. (place inside the 'sheet' of the excel object in the VBA editor, select "worksheet" and "change" in the top selections)Private Sub Worksheet_Change(ByVal Target As Range)If Target.Cells.Count > 1 Then Exit SubIf Not Intersect(Target, Range("B1")) Is Nothing Then On Error Resume Next Application.EnableEvents = False Run Test1() Application.EnableEvents = True On Error GoTo 0End IfEnd SubFor the Macro code you posted, change the first line to be ->Function Test1() change the last line to beEnd FunctionChange anywhere it says "Sub" to be "Function" instead. (say it says "Exit Sub", change it to "Exit Function").The rest looks OK... I think Link to comment Share on other sites More sharing options...
_Velocity_ Bronze Donating Members 2,768 Member For: 13y 9m 8d Gender: Male Location: Victoria Posted 30/09/13 04:53 AM Share Posted 30/09/13 04:53 AM Fark Nitro gym down here was shot the Fark up.. And bombs put in gym.. Thank god I don't train there no more.. Bloody bikie owned gyms!!!Just heard they had to call in more Police as a bunch of guys pepped up on 1MR, were raging because it's chest day. Link to comment Share on other sites More sharing options...
Never had any say Panda I <3 Floods Silver Donating Members 11,198 Member For: 13y 6m 1d Gender: Male Location: South West QLD Posted 30/09/13 05:07 AM Share Posted 30/09/13 05:07 AM You'll need a method in here with something along these lines, to trigger the macro you have here. (place inside the 'sheet' of the excel object in the VBA editor, select "worksheet" and "change" in the top selections)Private Sub Worksheet_Change(ByVal Target As Range)If Target.Cells.Count > 1 Then Exit SubIf Not Intersect(Target, Range("B1")) Is Nothing Then On Error Resume Next Application.EnableEvents = False Run Test1() Application.EnableEvents = True On Error GoTo 0End IfEnd SubFor the Macro code you posted, change the first line to be ->Function Test1() change the last line to beEnd FunctionChange anywhere it says "Sub" to be "Function" instead. (say it says "Exit Sub", change it to "Exit Function").The rest looks OK... I think Cheers mate.. I'll give it a crack tonight.. Link to comment Share on other sites More sharing options...
k31th less WHY; more WOT Site Developer 29,187 Member For: 16y 9m 23d Gender: Male Location: Melbourne Posted 30/09/13 05:14 AM Share Posted 30/09/13 05:14 AM No worries, just message me on Facebook or PM here if you need more help Link to comment Share on other sites More sharing options...
Corzza 777 Member 7,135 Member For: 16y 1d Gender: Male Location: Neutral Bay. Born and Bred in the RSA Posted 30/09/13 05:15 AM Share Posted 30/09/13 05:15 AM The count down is on! Link to comment Share on other sites More sharing options...
Pixy Angel Expert Donating Members 9,132 Member For: 19y 11m 6d Gender: Male Location: North Jamberoo, NSW Posted 30/09/13 06:07 AM Share Posted 30/09/13 06:07 AM Afternoon all having a good day?overload!! what a hectic day so much to take in. glade its over. Link to comment Share on other sites More sharing options...
Corzza 777 Member 7,135 Member For: 16y 1d Gender: Male Location: Neutral Bay. Born and Bred in the RSA Posted 30/09/13 06:19 AM Share Posted 30/09/13 06:19 AM Outta here now!Chat tomorrow guys! Link to comment Share on other sites More sharing options...
Pixy Angel Expert Donating Members 9,132 Member For: 19y 11m 6d Gender: Male Location: North Jamberoo, NSW Posted 30/09/13 07:19 AM Share Posted 30/09/13 07:19 AM catch ya corzza have a good one mate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now