Non contiguous cells

SWEETJONNYCRASH

New Member
Joined
Apr 23, 2012
Messages
5
Hi I am wondering if there is a way to take a non contiguous range of cells from sheet1 of my workbook and have them printed on every page? So if I want a1-a10 and g5-g10 to print on every page it will? Any help would be greatly appreciated.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Code:
Sub copyrangetosheets()
    Dim ws As Worksheet
 
    For Each ws In Worksheets
        
        ws.Range("A1:A10").Value = Sheets("SourceData").Range("A1:A10").Value
        ws.Range("G5:G10").Value = Sheets("SourceData").Range("G5:G10").Value
                     
        
    Next ws
        
End Sub

Change "SourceData" to the name of your original sheet
 
Upvote 0
That copies it to each Sheet in the workbook. What I want to do is basically take the range of cells and have it printed on each page that is printed. So if I print sheet1 and it goes on multiple pages these cells are printed on each page. I'm sorry I am new to this forum thing.
 
Upvote 0
Are the corresponding ranges on each following page blank? Or do you wish to replace text/values just when printing?
 
Upvote 0
I don't know how to alter Excel's function in the print page setup so that segments are repeated instead of whole rows or columns. I can give you a macro to detect page breaks and paste the ranges n cells above, but it will replace the blanks unless you or the macro creates a copy first.
 
Upvote 0

Excel 2003
ABCDEFG
1NameNumberNextNameNextNumber
2Billings104,170Yellowstone408,698
3Missoula66,789Missoula746,367
4Great Falls58,505Cascade974,535
5Bozeman37,280Gallatin757,299Gallatin
6Butte34,525Silver Bow553,122Silver Bow
7Helena28,190Lewis and Clark663,335Lewis and Clark
8Kalispell19,927Flathead23,253Flathead
9Havre9,310Hill712,138Hill
10Anaconda9,298Deer Lodge146,202Deer Lodge
118,123Custer615,015
127,389Gallatin818,323
137,044Park843,439
146,781Yellowstone390,148
156,357Flathead323,615
165,901Fergus504,941
175,191Richland111,206
184,935Dawson578,118
194,688Flathead310,916
204,598Lake766,566
214,348Ravalli381,227
224,134Beaverhead855,205
233,505Big Horn896,694
243,376Toole709,113
253,250Valley280,084
263,111Powell347,472
272,869Glacier211,660
282,628Lincoln474,379
292,621Roosevelt411,596
302,570Pondera822,763
312,214Rosebud512,101
322,125Carbon928,540
331,997Phillips558,792
341,984Lewis and Clark987,166
351,893Stillwater678,179
361,878Broadwater43,877
371,871Lake445,993
381,869Gallatin274,830
391,809Ravalli468,798
401,788Musselshell298,098
411,777Rosebud827,919
421,741Fallon791,472
431,641Sweet Grass327,908
441,684Teton475,151
451,520Gallatin627,192
461,734Sheridan19,940
471,464Chouteau668,769
481,313Sanders67,553
491,271Gallatin932,138
501,203Blaine723,260
511,183Jefferson473,585
521,048Sanders363,092
531,038Jefferson911,226
541,037Lincoln272,206
551,017Daniels318,310
561,016Glacier469,174
57997Wheatland474,154
58939Meagher866,421
59938Lincoln427,030
60917Ravalli27,832
61847Liberty356,726
62842Lake613,509
63840Richland882,682
64838Madison334,243
65820Granite956,811
66812Mineral761,528
67810Roosevelt561,256
68808Blaine759,127
69720Ravalli811,715
70714Roosevelt892,608
71708Carbon39,814
72708Teton868,966
73685Cascade928,645
74675Silver Bow863,180
75642Madison932,403
76615McCone547,023
77605Prairie998,654
78598Chouteau759,782
79597Cascade683,857
80595Carbon605,970
81589Wibaux31,292
82544Sanders860,737
83509Pondera771,994
84468Powder River777,889
85438Carbon908,762
86428Big Horn214,068
87420Mineral169,076
88401Judith Basin104,699
89375Toole577,529
90375Madison650,573
91343Garfield31,696
92332Carter48,674
93316Teton800,623
94312Treasure213,946
95309Granite126,042
96290Valley747,363
97288Park907,318
98261Chouteau670,683
99255Roosevelt92,096
100255Fergus337,661
Sheet4 (4)



Code:
Sub printsectionbeforeeachpagebreak()
Dim x As Integer
Dim LR As Integer
LR = Range("B" & Rows.Count).End(xlUp).Row 'or whatever column/value equals the number of rows
For x = 1 To LR
If Cells(x, 1).EntireRow.PageBreak <> -4142 Then Range("G" & x + 4 & ":" & "G" & (x + 9)) = Range("G5:G10").Value
If Cells(x, 1).EntireRow.PageBreak <> -4142 Then Range("A" & x & ":" & "A" & (x + 9)) = Range("A1:A10").Value
Next
End Sub


Excel 2003
ABCDEFG
1NameNumberNextNameNextNumber
2Billings104,170Yellowstone408,698
3Missoula66,789Missoula746,367
4Great Falls58,505Cascade974,535
5Bozeman37,280Gallatin757,299Gallatin
6Butte34,525Silver Bow553,122Silver Bow
7Helena28,190Lewis and Clark663,335Lewis and Clark
8Kalispell19,927Flathead23,253Flathead
9Havre9,310Hill712,138Hill
10Anaconda9,298Deer Lodge146,202Deer Lodge
118,123Custer615,015
127,389Gallatin818,323
137,044Park843,439
146,781Yellowstone390,148
156,357Flathead323,615
165,901Fergus504,941
175,191Richland111,206
184,935Dawson578,118
194,688Flathead310,916
204,598Lake766,566
214,348Ravalli381,227
224,134Beaverhead855,205
233,505Big Horn896,694
243,376Toole709,113
253,250Valley280,084
263,111Powell347,472
272,869Glacier211,660
282,628Lincoln474,379
292,621Roosevelt411,596
302,570Pondera822,763
312,214Rosebud512,101
322,125Carbon928,540
331,997Phillips558,792
341,984Lewis and Clark987,166
351,893Stillwater678,179
361,878Broadwater43,877
371,871Lake445,993
381,869Gallatin274,830
391,809Ravalli468,798
401,788Musselshell298,098
411,777Rosebud827,919
421,741Fallon791,472
431,641Sweet Grass327,908
441,684Teton475,151
451,520Gallatin627,192
461,734Sheridan19,940
471,464Chouteau668,769
481,313Sanders67,553
491,271Gallatin932,138
501,203Blaine723,260
511,183Jefferson473,585
521,048Sanders363,092
53Name1,038Jefferson911,226
54Billings1,037Lincoln272,206
55Missoula1,017Daniels318,310
56Great Falls1,016Glacier469,174
57Bozeman997Wheatland474,154Gallatin
58Butte939Meagher866,421Silver Bow
59Helena938Lincoln427,030Lewis and Clark
60Kalispell917Ravalli27,832Flathead
61Havre847Liberty356,726Hill
62Anaconda842Lake613,509Deer Lodge
63840Richland882,682
64838Madison334,243
65820Granite956,811
66812Mineral761,528
67810Roosevelt561,256
68808Blaine759,127
69720Ravalli811,715
70714Roosevelt892,608
71708Carbon39,814
72708Teton868,966
73685Cascade928,645
74675Silver Bow863,180
75642Madison932,403
76615McCone547,023
77605Prairie998,654
78598Chouteau759,782
79597Cascade683,857
80595Carbon605,970
81589Wibaux31,292
82544Sanders860,737
83509Pondera771,994
84468Powder River777,889
85438Carbon908,762
86428Big Horn214,068
87420Mineral169,076
88401Judith Basin104,699
89375Toole577,529
90375Madison650,573
91343Garfield31,696
92332Carter48,674
93316Teton800,623
94312Treasure213,946
95309Granite126,042
96290Valley747,363
97288Park907,318
98261Chouteau670,683
99255Roosevelt92,096
100255Fergus337,661
Sheet4 (4)
 
Upvote 0
Well actually I can use the whole rows. My problem is that when you do the range in print setup they can't be non contiguous. I actually want rows 1-7 and rows 16&17 to print at the top of each page. Is that possible?
 
Upvote 0
The code above can be changed for any range, but it will still replace info in the sheet rather than only appear when printing.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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