Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 360
Default problem setting the used range for a column

Can you help me out. The "set range" line doesn't compile. I just need the
used range in column A. It needs to be relative because the user can change
it.
thanks
Private Sub UserForm_Initialize()

Dim intLastRow As Integer
Dim ws As Worksheet
Dim c As Range
Dim rng As Range

ws = xl.Worksheets("patients").Activate()
intLastRow = ws.Cells.SpecialCells(xlCellTypeLastCell).Row



SEt rng = Worksheets("patients").Range("A1":A&intLastRow)
ComboBox2.Clear
For Each c In Worksheets("patients").rng
ComboBox2.AddItem c.Value
Next c

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default problem setting the used range for a column

Janis,

Try this

Set rng = Worksheets("patients").Range("A1:A" & intLastRow)

Mike

"Janis" wrote:

Can you help me out. The "set range" line doesn't compile. I just need the
used range in column A. It needs to be relative because the user can change
it.
thanks
Private Sub UserForm_Initialize()

Dim intLastRow As Integer
Dim ws As Worksheet
Dim c As Range
Dim rng As Range

ws = xl.Worksheets("patients").Activate()
intLastRow = ws.Cells.SpecialCells(xlCellTypeLastCell).Row



SEt rng = Worksheets("patients").Range("A1":A&intLastRow)
ComboBox2.Clear
For Each c In Worksheets("patients").rng
ComboBox2.AddItem c.Value
Next c

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 360
Default problem setting the used range for a column

Thanks very much for your speedy reply.
"Mike H" wrote:

Janis,

Try this

Set rng = Worksheets("patients").Range("A1:A" & intLastRow)

Mike

"Janis" wrote:

Can you help me out. The "set range" line doesn't compile. I just need the
used range in column A. It needs to be relative because the user can change
it.
thanks
Private Sub UserForm_Initialize()

Dim intLastRow As Integer
Dim ws As Worksheet
Dim c As Range
Dim rng As Range

ws = xl.Worksheets("patients").Activate()
intLastRow = ws.Cells.SpecialCells(xlCellTypeLastCell).Row



SEt rng = Worksheets("patients").Range("A1":A&intLastRow)
ComboBox2.Clear
For Each c In Worksheets("patients").rng
ComboBox2.AddItem c.Value
Next c

End Sub

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
recalc setting by range Steve Excel Discussion (Misc queries) 1 December 14th 07 04:22 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Problem setting SeriesCollections source range Lead Foot Charts and Charting in Excel 2 January 27th 06 05:11 AM
VBA setting Range Jeff Excel Discussion (Misc queries) 1 December 2nd 05 07:36 PM
VBA setting range in another sheet Jeff Excel Discussion (Misc queries) 2 October 14th 05 02:11 PM


All times are GMT +1. The time now is 05:49 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"