|
-
Mar 12th, 2006, 07:53 PM
#1
Thread Starter
Junior Member
[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
-
Mar 12th, 2006, 09:35 PM
#2
Addicted Member
Re: Selecting ranges
Close:
VB Code:
Option Explicit
Sub Macro1()
Range("A1", ActiveCell).Select
End Sub
-
Mar 12th, 2006, 10:09 PM
#3
Thread Starter
Junior Member
Re: Selecting ranges
Thank you Malik. I could have sworn I tried that line of code, but I guess I didn't because it works perfectly.
Thanks again,
Danno
-
Mar 12th, 2006, 11:04 PM
#4
Thread Starter
Junior Member
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
-
Mar 13th, 2006, 09:41 AM
#5
Addicted Member
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
-
Mar 13th, 2006, 08:00 PM
#6
Thread Starter
Junior Member
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
-
Mar 14th, 2006, 09:51 AM
#7
Addicted Member
Re: [RESOLVED] Selecting ranges
Hey glad to help Danno
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|