Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default column of a input box selected range

I have an inputbox which captures a user selected range.

From this range, i am able to get the column number via range.column

is there a easy way to reference this column in vba?

currently, i'm using range(cell(1,column#),cell(65000,column#)) which seems
like a complicated way to select the column

i'm hoping there's something like column(column#).select


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default column of a input box selected range

Hi Dennis,

Is the following example what you want?

Dim colNumber As Long

colNumber = 8

Columns(colNumber).Select

--
Regards,

OssieMac


"Dennis Chou" wrote:

I have an inputbox which captures a user selected range.

From this range, i am able to get the column number via range.column

is there a easy way to reference this column in vba?

currently, i'm using range(cell(1,column#),cell(65000,column#)) which seems
like a complicated way to select the column

i'm hoping there's something like column(column#).select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default column of a input box selected range

actually,

how would i reference that in a worksheet function?

This does not appear to work

Range("b2").Value = WorksheetFunction.SumIf( _
Sheets(UserForm1.ID_sheet_name_1).Columns(1).Addre ss, _
Sheets("compare").Range("a2"), _
Sheets(UserForm1.ID_sheet_name_1).Columns(2).Addre ss)


"OssieMac" wrote in message
...
Hi Dennis,

Is the following example what you want?

Dim colNumber As Long

colNumber = 8

Columns(colNumber).Select

--
Regards,

OssieMac


"Dennis Chou" wrote:

I have an inputbox which captures a user selected range.

From this range, i am able to get the column number via range.column

is there a easy way to reference this column in vba?

currently, i'm using range(cell(1,column#),cell(65000,column#)) which
seems
like a complicated way to select the column

i'm hoping there's something like column(column#).select





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default column of a input box selected range

Hello again Dennis,

Address returns a string like the following.
MsgBox Columns(1).Address

Untested but I think your code should be;

Range("b2").Value = WorksheetFunction.SumIf( _
Sheets(UserForm1_ID).Columns(1), _
Sheets("compare").Range("a2"), _
Sheets(UserForm1_ID).Columns(2))

--
Regards,

OssieMac

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default column of a input box selected range

Just for you interest Dennis you can use the address string in lieu of a cell
range that is inserted between double quotes when using in conjunction with
Range.

Range("b2").Value = WorksheetFunction.SumIf( _
Sheets(UserForm1_ID).Range(Columns(1).Address), _
Sheets("compare").Range("a2"), _
Sheets(UserForm1_ID).Range(Columns(2).Address))

Note that Columns(1).Address is a variable that replaces the part between
the double quotes in range("A:A").


--
Regards,

OssieMac




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default column of a input box selected range

Range("b2").Value = WorksheetFunction.SumIf( _
Sheets(UserForm1.ID_sheet_name_1).Columns(1), _
Sheets("compare").Range("a2").value, _
Sheets(UserForm1.ID_sheet_name_1).Columns(2))

Use ranges for the first and third parm.

(I added the .value because I don't like to depend on the default
properties--but your code doesn't need it.)

untested, uncompiled. I just modified your code.

Dennis Chou wrote:

actually,

how would i reference that in a worksheet function?

This does not appear to work

Range("b2").Value = WorksheetFunction.SumIf( _
Sheets(UserForm1.ID_sheet_name_1).Columns(1).Addre ss, _
Sheets("compare").Range("a2"), _
Sheets(UserForm1.ID_sheet_name_1).Columns(2).Addre ss)

"OssieMac" wrote in message
...
Hi Dennis,

Is the following example what you want?

Dim colNumber As Long

colNumber = 8

Columns(colNumber).Select

--
Regards,

OssieMac


"Dennis Chou" wrote:

I have an inputbox which captures a user selected range.

From this range, i am able to get the column number via range.column

is there a easy way to reference this column in vba?

currently, i'm using range(cell(1,column#),cell(65000,column#)) which
seems
like a complicated way to select the column

i'm hoping there's something like column(column#).select




--

Dave Peterson
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
sheet protection - only selected range to be able to select/input data Corey Excel Worksheet Functions 7 February 13th 07 05:41 PM
Find last row and column in a selected range Bernie Deitrick Excel Programming 0 December 20th 06 02:41 PM
Choose data from a selected range and put result in new column Betsy Excel Worksheet Functions 2 July 1st 06 04:13 AM
Referencing a Column in a Selected Range of Columns Rob G Excel Programming 3 October 21st 04 05:21 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 01:28 AM.

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"