Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Range Efficeincy

Hello,

Please can someone show me a peice of code that select the cells from a
column where there is an existing value excluding the column header?

I currently have a workbook where I'm trying to populate a number of
combo boxes using a variable worksheet, this worksheet is regularly
updated by other users but I need my code to select all popluated
cells.

For example I need to call a range of week numbers that reside in
column A, these may change frequently so this range needs to be
flexible enough to pick up all cells.


Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Range Efficeincy

Hi Steven,

Try something like:

'=============
Public Sub Tester004()
Dim rng As Range
Dim LRow As Long
Const col As String = "A" '<<==== CHANGE

LRow = Cells(Rows.Count, col).End(xlUp).Row

Set rng = Range("A2:A" & LRow)

End Sub
'<<=============


---
Regards,
Norman


"Steven" wrote in message
ups.com...
Hello,

Please can someone show me a peice of code that select the cells from a
column where there is an existing value excluding the column header?

I currently have a workbook where I'm trying to populate a number of
combo boxes using a variable worksheet, this worksheet is regularly
updated by other users but I need my code to select all popluated
cells.

For example I need to call a range of week numbers that reside in
column A, these may change frequently so this range needs to be
flexible enough to pick up all cells.


Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Range Efficeincy

Thanks!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Range Efficeincy

Is there anyway of not hard coding the column to A?

Currently I have different variables stored from Cols A to G?

Apologies I'm new to this.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Range Efficeincy

Hi Steven,

Try:

'=============
Public Sub Tester004()
Dim rng As Range
Dim LRow As Long
Const col As String = "A" '<<==== CHANGE

LRow = Cells(Rows.Count, col).End(xlUp).Row

Set rng = Range(col & "2:" & col & LRow)

End Sub
'<<=============

---
Regards,
Norman



"Steven" wrote in message
ups.com...
Is there anyway of not hard coding the column to A?

Currently I have different variables stored from Cols A to G?

Apologies I'm new to this.



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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
find efficeincy kevcar40 Excel Discussion (Misc queries) 4 November 21st 05 03:33 PM
find efficeincy kevcar40 Excel Discussion (Misc queries) 0 November 21st 05 10:08 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 08:36 PM.

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

About Us

"It's about Microsoft Excel"