[RESOLVED] Selecting ranges
I need my Excel spreadsheet to have the ability to select the range from the active cell all the way back to cell A1. I've been writing code for this seemingly simple problem all day and nothing gets past the debugger. For example:
Range("A1":Range(ActiveCell)).Select
Can anyone help?
Danno :blush:
Re: [RESOLVED] Selecting ranges
Malik641 I need you again!
I'm trying to write a macro that will do the following: The user will click on a cell, that active cell and everything back to cell A1 gets selected and print area set, then print a number of copies. With the help of your line of code I've gotten it to select the desired range, but it prints out the entire worksheet not just the selected range.
Danno :blush:
Re: [RESOLVED] Selecting ranges
Like this?
VB Code:
Option Explicit
Sub Danno()
Dim selectedRng As Range
Set selectedRng = Range("A1", ActiveCell)
selectedRng.Select 'This could be left out.
ActiveSheet.PageSetup.PrintArea = selectedRng.Address
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Preview:=False, _
ActivePrinter:="Your printer", Collate:=True
End Sub
Re: [RESOLVED] Selecting ranges
Malik,
Works perfectly, thank you. I've tried so many iterations that I've forgotten what I wrote. I thought for sure that one of my code attempts had your line: Set selectedRng = Range("A1", ActiveCell) and it did not work. But this line was my missing link and yours works just right.
Thanks very much,
Danno :thumb: :thumb:
Re: [RESOLVED] Selecting ranges
Hey glad to help Danno :thumb: