|
-
Oct 8th, 2009, 02:15 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Seleting specific range
I am using Excel 2007.
It seems so simple, but I can't piece together the last line of code. I'm drawing a blank for some reason.
Code:
'Stores the number of the last row
Range("G1").Select
Selection.End(xlDown).Select
intLastRow = ActiveCell.Row
'Stores the number of the last column
Range("G1").Select
Selection.End(xlToRight).Select
intLastColumn = ActiveCell.Column
What I'm trying to do is select the entire group range. I tried using...
Range("G1", ????).select
The problem here is if I use intLastColumn it'll give me the # of the column (Ex. A = 1, B = 2, C = 3, etc). I need the letter so I can put...
"P" & intLastRow
...in orde to select the entire group. Is there a way to Convert the number back to the column letter or even store the Column letter rather than the #?
-
Oct 8th, 2009, 02:28 PM
#2
Re: Seleting specific range
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 8th, 2009, 02:45 PM
#3
Thread Starter
Hyperactive Member
-
Oct 8th, 2009, 02:48 PM
#4
Re: Seleting specific range
Do you want the range G1:L7 ?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 8th, 2009, 02:55 PM
#5
Thread Starter
Hyperactive Member
Re: Seleting specific range
Yes, I do. But I have to keep in mind that the number of rows & columns can change every month. And, the cells in the middle don't always have data just as in the example.
That's why in the example I provided I was storing the last row/column so I could trying to select the entire group by entering...
Range("G1", ????).Select
Last edited by lilmark; Oct 8th, 2009 at 03:00 PM.
-
Oct 8th, 2009, 02:57 PM
#6
Re: Seleting specific range
Ok will the first row and the first column have data always? if yes then this will help you...
vb Code:
Sub GetRangeAddress() Range(Range("D7"), Range("D7").End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select MsgBox Selection.Address End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 8th, 2009, 03:26 PM
#7
Thread Starter
Hyperactive Member
Re: Seleting specific range
Figured how to select the entire group where the rows/columns aren't always constant...
Code:
Dim intLastRow As Integer
Range("G1").Select
Selection.End(xlDown).Select
intLastRow = ActiveCell.Row
Range("G1").Select
Selection.End(xlToRight).Select
Range("G1", ActiveCell.Offset(intLastRow - 1, 0)).Select
Wish you could store the column letter rather than the number of columns.
-
Oct 8th, 2009, 03:28 PM
#8
Re: [RESOLVED] Seleting specific range
Figured how to select the entire group where the rows/columns aren't always constant...
Not even the 1st row and 1st column?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
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
|