+ Reply to Thread
Results 1 to 4 of 4

Selected cells in Vba?

  1. #1
    Registered User
    Join Date
    09-26-2006
    Posts
    2

    Selected cells in Vba?

    Hello,

    I would like to select a range of cells manually and then, through a macro, I want to define the selected zone as print area in order to print it.

    I don't know what's the syntax to get the "manualy" selected cells in the code.

    so I would like something like

    ActiveSheet.PageSetup.PrintArea = "my selected cells"

    Many thanks for your help and for this forum! it's great
    Johann

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Would this help
    Sub InputBoxTest()
    Dim MySelection As Range
    Set MySelection = Application.InputBox(prompt:="Select a range of cells", Type:=8)
    MySelection.Select
    Selection.PrintOut Copies:=1, Collate:=True
    End Sub

  3. #3
    Registered User
    Join Date
    09-26-2006
    Posts
    2
    Thanks for your answer.

    In fact I would like to define as print area, by a macro, the cells I highlighted manually.

    I know it may sound weird but I have like 20 pivot tables to print each month and I have to check them first manually. they are all different in size, so I would like to select them manually and then by macro, define this zone as print area and print it. I know the second part of macro but I can't find out how I can have

    ActiveSheet.PageSetup.PrintArea ="my current worksheet highlighted cells"

    Thansk

  4. #4
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Not sure I understand your requirement, if you run the previous macro or this
    one. The macro will prompt you to select a range, once the selection is made by the user then it will define a print area and will make one copy of the selected cells.


    Sub InputBoxTest()
    Dim MySelection As Range
    Set MySelection = Application.InputBox(prompt:="Select a range of cells", Type:=8)
    MySelection.Select
    ActiveSheet.PageSetup.PrintArea = Selection.Address
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1