Macro for a selected data

bombur10

New Member
Joined
Sep 21, 2006
Messages
4
Hi, I want to run a macro where I want to be able to see a certain range of data in a print preview. My problem is, let's say I move the data over somewhere else, I want the macro to follow the data and not stay at the previous range. Does that make sense? Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi -
Welcome to the board.
try this;
Select the range > Insert > Name > define and named it as "test"
then write a macro like this;
Code:
sub followdata()
range("test").printpreview
End Sub
 
Upvote 0
what happens if the area of data I want to select are from two separate places. How can I select the stuff I want to see in print preview? Thanks
 
Upvote 0
select the first cell, hold Ctrl key then select the other cell, then define the name as previously instructed, then run this code;

Code:
Sub followdata()
Range("test").Select
ActiveWindow.SelectedSheets.PrintPreview
End Sub
 
Upvote 0
Well if I record a macro, it gives me this:
Sub Macro5()
'
' Macro5 Macro
Macro recorded 9/21/2006 by xxx

How do I put your part in afterwards without the sub part? It won't let me do it twice. Thanks
 
Upvote 0
Okay I think I'm supposed to find the region that I defined. So if I defined a region and called it ("Test"), how do I select the region and make it my currentregion? This way if I move the data ("Test"), I still want to print preview the data and not the wrong region. Thanks people
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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