VBA - Splitting a long line of code on to seperate lines

lemondifficult

New Member
Joined
Mar 19, 2014
Messages
40
Hi,

there is probably a very simple solution to this, however i cant seem to find it. Im looking to create a macro that hides around 300 specific lines of a spreadsheet.

I have the code written, however when compiling i get a syntax error probably because one of the lines is extremely long. Can anyone help me in putting this code in a format that will work? I have provided the code below;

Code:
    Sub Macro3()
Range("13:13,16:16,19:19,22:22,25:25,28:28,31:31,34:34,37:37,40:40,43:43,46:46,49:49,52:52,55:55,58:58,61:61,64:64,67:67,70:70,73:73,76:76,79:79,82:82,85:85,88:88,91:91,94:94,97:97,100:100,103:103,106:106,109:109,112:112,115:115,118:118,121:121,124:124,127:127,130:130,133:133,232:232,235:235,238:238,241:241,244:244,247:247,250:250,253:253,256:256,259:259,262:262,265:265,268:268,271:271,274:274,277:277,280:280,283:283,286:286,289:289,292:292,295:295,298:298,301:301,304:304,307:307,310:310,313:313,316:316,319:319,322:322,325:325,328:328,331:331,334:334,337:337,340:340,343:343,346:346,349:349,352:352,355:355,358:358,361:361,364:364,367:367,370:370,373:373,376:376,379:379,382:382,385:385,388:388,391:391,394:394,397:397,400:400,403:403,406:406,409:409,412:412,415:415,418:418,421:421,424:424,427:427,430:430,433:433,436:436,439:439,442:442,445:445,448:448,451:451,454:454,457:457,460:460,463:463,466:466,469:469,472:472,475:475,478:478,481:481,484:484,487:487,490:490,493:493,496:496,499:499,502:502,505:505,508:508,511:511,514:514,517:517,520:520,523:523,526:526,529:529,532:532,535:535,538:538,541:541,544:544,547:547,550:550,553:553,556:556,559:559,562:562,565:565,568:568,571:571,574:574,577:577,580:580,583:583,586:586,589:589,592:592,595:595,598:598,601:601,604:604,607:607,610:610,613:613,616:616,619:619,622:622,625:625,628:628,631:631,634:634,637:637,640:640,643:643,646:646,649:649,652:652,655:655,658:658,661:661,664:664,667:667,670:670,673:673,676:676,679:679,682:682,685:685,688:688,691:691,694:694,697:697,700:700,703:703,706:706,709:709,712:712,715:715,718:718,721:721,724:724,727:727,730:730,733:733,736:736,739:739,742:742,745:745,748:748,751:751,754:754,757:757,760:760,763:763,766:766,769:769,772:772,775:775,778:778,781:781,784:784,787:787,790:790,793:793,796:796,799:799,802:802,805:805,808:808,811:811,814:814,817:817,820:820,823:823,826:826,829:829,832:832,835:835,838:838,841:841,844:844,847:847,850:850,853:853,856:856,859:859,862:862,865:865,868:868,871:871,874:874,877:877,880:880,883:883,886:886,889:889,892:892,895:895,898:898,901:901,904:904,907:907,910:910,913:913,136:136,139:139,142:142,145:145,148:148,151:151,154:154,157:157,160:160,163:163,166:166,169:169,172:172,175:175,178:178,181:181,184:184,187:187,190:190,193:193,196:196,199:199,202:202,205:205,208:208,211:211,214:214,217:217,220:220,223:223,226:226,229:229").Select
    Range("F913").Activate
    Selection.EntireRow.Hidden = True
End Sub

any help is appreciated. thanks in advance.

Micheal
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hiya
I haven't checked all your numbers, but it looks to be in steps of 3, so how about something like this
Code:
Sub ThreeRws()

    Dim i As Integer

    For i = 13 To 913 Step 3
        Rows(i).Hidden = True
    Next i

End Sub
HTH
 
Upvote 0
FYI, the Range statement will only accept 255 characters as its argument, so you'd have had to Union several ranges to do it your original way.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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