Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Mike
 
Posts: n/a
Default Whats wrong with this macro please

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Whats wrong with this macro please

You could use something like:

With ActiveSheet
.PageSetup.PrintArea = "a8:b8"
.PrintOut preview:=True
End With

Or maybe without changing the printrange...

ActiveSheet.Range("a8:b8").PrintOut preview:=True

Mike wrote:

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Mike
 
Posts: n/a
Default Whats wrong with this macro please

Thanks Dave
That works brilliantly, is there a way to record how many times the button
is pressed as well please
--
thanks


"Dave Peterson" wrote:

You could use something like:

With ActiveSheet
.PageSetup.PrintArea = "a8:b8"
.PrintOut preview:=True
End With

Or maybe without changing the printrange...

ActiveSheet.Range("a8:b8").PrintOut preview:=True

Mike wrote:

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Whats wrong with this macro please

You could use a cell in a worksheet (that's hidden).

ActiveSheet.Range("a8:b8").PrintOut preview:=True
with worksheets("hiddennamehere").range("a1")
if isnumeric(.value) then
.value = .value + 1
else
.value = 1
end if
end with

But if you use this kind of thing, then you have to save the workbook -- so that
the counter gets saved for the next time.

And it's not always a good thing to just save a workbook without knowing the
other changes that have been made. Is there a real reason to care?

Mike wrote:

Thanks Dave
That works brilliantly, is there a way to record how many times the button
is pressed as well please
--
thanks

"Dave Peterson" wrote:

You could use something like:

With ActiveSheet
.PageSetup.PrintArea = "a8:b8"
.PrintOut preview:=True
End With

Or maybe without changing the printrange...

ActiveSheet.Range("a8:b8").PrintOut preview:=True

Mike wrote:

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Jim May
 
Posts: n/a
Default Whats wrong with this macro please

Keep in mind that the cell reference A8:b8 will not change (in your code
module) if in the excel sheet (interface) "someone" moves your range or
inserts a row or column; Giving A8:B8 a name would improve such things.

HTH

"Dave Peterson" wrote in message
...
You could use something like:

With ActiveSheet
.PageSetup.PrintArea = "a8:b8"
.PrintOut preview:=True
End With

Or maybe without changing the printrange...

ActiveSheet.Range("a8:b8").PrintOut preview:=True

Mike wrote:

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different
range of
cells on same sheet i used this
"ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying
there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.misc
Trevor Shuttleworth
 
Posts: n/a
Default Whats wrong with this macro please

Mike

try:

With ActiveSheet
.PageSetup.PrintArea = "A8:B8"
.PrintPreview
' .PrintOut
End With

Regards

Trevor


"Mike" wrote in message
...
Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range
of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea
=
"A8:B8" to try and doi it changing the print area but it keeps saying
there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike



  #7   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Whats wrong with this macro please

Try:
ActiveSheet.PageSetup.PrintArea = "$A$1:$B$8"
--
Gary''s Student


"Mike" wrote:

Hi
All i want to do is press a form button and print out a cell range, there
are multiple buttons on the spreadsheet each on to print a different range of
cells on same sheet i used this "ActiveSheet.PrintOut.PageSetup.PrintArea =
"A8:B8" to try and doi it changing the print area but it keeps saying there
is an error, any ideas anybody please, or is there another way to do it
--
thanks
Mike

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can T Get Macro To Run! Nipper New Users to Excel 2 November 4th 05 04:48 AM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM
Macro help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"