Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Referencing columns in formula

I started out selecting a range like this:
Range("B13:G13").Select

Then I realized that I wanted to use a variable for the row instead of 13
and changed it to this:
Range("B" & strRow & ":G" & strRow).Select

Now I want to be able to use a variable for the column. I'd like to select
"B" through the 5th column over ("G") or if my starting column is "I" then
select through the 5th column over ("N"). Below is wrong, but what would be
correct?
Range(strCol & strRow & ":" & (strCol + 5) & strRow).Select

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Referencing columns in formula

Use the Cells property in combination with Resize to do what you want...

Cells(strRow, strCol).Resize(, 5).Select

Although I'm willing to bet you don't actually need to select the range in
order to do whatever it is you want to do to the range (you didn't tell us).
By the way, strCol can either be the column number or column letter... the
Cells property will tolerate both forms of specifying the column.

--
Rick (MVP - Excel)


"Bigfoot17" wrote in message
...
I started out selecting a range like this:
Range("B13:G13").Select

Then I realized that I wanted to use a variable for the row instead of 13
and changed it to this:
Range("B" & strRow & ":G" & strRow).Select

Now I want to be able to use a variable for the column. I'd like to
select
"B" through the 5th column over ("G") or if my starting column is "I" then
select through the 5th column over ("N"). Below is wrong, but what would
be
correct?
Range(strCol & strRow & ":" & (strCol + 5) & strRow).Select

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Referencing columns in formula

This should give you a few ideas:

Sub SelRange()
Dim MyRng As Range
Set r = Application.InputBox(prompt:="select range with mouse", Type:=8)
r.Select
If TypeOf Selection Is Range Then
Set MyRng = Selection
End If
End Sub

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Bigfoot17" wrote:

I started out selecting a range like this:
Range("B13:G13").Select

Then I realized that I wanted to use a variable for the row instead of 13
and changed it to this:
Range("B" & strRow & ":G" & strRow).Select

Now I want to be able to use a variable for the column. I'd like to select
"B" through the 5th column over ("G") or if my starting column is "I" then
select through the 5th column over ("N"). Below is wrong, but what would be
correct?
Range(strCol & strRow & ":" & (strCol + 5) & strRow).Select

Thanks!

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
Formula Referencing Columns By Date Rob Excel Worksheet Functions 2 November 11th 09 11:42 PM
Referencing columns as rows bob135 Excel Discussion (Misc queries) 8 April 13th 06 01:22 PM
Referencing Columns in a Row. PLEASE HELP!! Chism Henry via OfficeKB.com Excel Worksheet Functions 2 June 25th 05 03:25 AM
I need to Sum multiple columns by referencing one formula GaryZ Excel Programming 2 July 3rd 04 03:44 PM
Referencing two columns for data Todd S[_3_] Excel Programming 1 October 2nd 03 04:48 AM


All times are GMT +1. The time now is 02:44 PM.

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

About Us

"It's about Microsoft Excel"