PC Review


Reply
Thread Tools Rate Thread

Define range by last cell in column?

 
 
AUCP03
Guest
Posts: n/a
 
      27th Aug 2009
I have a userform listbox. This list box is currently populated by range
A4,F173 Column F is the only one with an entry in every used row. All rows
from A4 to F(last row) will have data in them, but not in all columns except
for column F. How can I define this range to capture the range from
A4,F(last used)?
 
Reply With Quote
 
 
 
 
AUCP03
Guest
Posts: n/a
 
      27th Aug 2009
This is what I have been trying to get to work.

Private Sub UserForm_Initialize()
Me.ListBox1.Clear

Dim ListBoxRange As Range
Dim LastRow As Long

LastRow = Cells(Rows.Count, "F").End(xlUp).Row

Set ListBoxRange = Range(A4, Cells(LastRow, "F"))

Me.ListBox1.List = Sheet1.Range("ListBoxRange").Value
End Sub

"AUCP03" wrote:

> I have a userform listbox. This list box is currently populated by range
> A4,F173 Column F is the only one with an entry in every used row. All rows
> from A4 to F(last row) will have data in them, but not in all columns except
> for column F. How can I define this range to capture the range from
> A4,F(last used)?

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      27th Aug 2009
Private Sub UserForm_Initialize()

Dim ListBoxRange As Range
Dim LastRow As Long

with worksheets("somesheetnamehere")
LastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
Set ListBoxRange = .Range("A4:F" & LastRow)
end with

with me.listbox1
.clear
.columncount = listboxrange.columns.count
.list = listboxrange.value
end with

End Sub

AUCP03 wrote:
>
> This is what I have been trying to get to work.
>
> Private Sub UserForm_Initialize()
> Me.ListBox1.Clear
>
> Dim ListBoxRange As Range
> Dim LastRow As Long
>
> LastRow = Cells(Rows.Count, "F").End(xlUp).Row
>
> Set ListBoxRange = Range(A4, Cells(LastRow, "F"))
>
> Me.ListBox1.List = Sheet1.Range("ListBoxRange").Value
> End Sub
>
> "AUCP03" wrote:
>
> > I have a userform listbox. This list box is currently populated by range
> > A4,F173 Column F is the only one with an entry in every used row. All rows
> > from A4 to F(last row) will have data in them, but not in all columns except
> > for column F. How can I define this range to capture the range from
> > A4,F(last used)?


--

Dave Peterson
 
Reply With Quote
 
AUCP03
Guest
Posts: n/a
 
      28th Aug 2009
Thank you for the help Mr. Peterson! It works great.

"Dave Peterson" wrote:

> Private Sub UserForm_Initialize()
>
> Dim ListBoxRange As Range
> Dim LastRow As Long
>
> with worksheets("somesheetnamehere")
> LastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
> Set ListBoxRange = .Range("A4:F" & LastRow)
> end with
>
> with me.listbox1
> .clear
> .columncount = listboxrange.columns.count
> .list = listboxrange.value
> end with
>
> End Sub
>
> AUCP03 wrote:
> >
> > This is what I have been trying to get to work.
> >
> > Private Sub UserForm_Initialize()
> > Me.ListBox1.Clear
> >
> > Dim ListBoxRange As Range
> > Dim LastRow As Long
> >
> > LastRow = Cells(Rows.Count, "F").End(xlUp).Row
> >
> > Set ListBoxRange = Range(A4, Cells(LastRow, "F"))
> >
> > Me.ListBox1.List = Sheet1.Range("ListBoxRange").Value
> > End Sub
> >
> > "AUCP03" wrote:
> >
> > > I have a userform listbox. This list box is currently populated by range
> > > A4,F173 Column F is the only one with an entry in every used row. All rows
> > > from A4 to F(last row) will have data in them, but not in all columns except
> > > for column F. How can I define this range to capture the range from
> > > A4,F(last used)?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
define range using col and row names; not cell name cate Microsoft Excel Programming 3 27th Feb 2010 04:12 PM
Add Edit/Define Range Name to right click on cell =?Utf-8?B?TWFya21teA==?= Microsoft Excel Misc 0 26th Oct 2006 12:54 AM
Define a range of rows having the same value in one column gimme_this_gimme_that@yahoo.com Microsoft Excel Programming 4 6th Oct 2006 08:17 PM
How to retrieve a column number and apply it to define a range? Frank Krogh Microsoft Excel Worksheet Functions 6 9th Mar 2004 02:13 PM
define end column in a range Chris Perry Microsoft Excel Programming 1 1st Oct 2003 08:13 PM


Features
 

Advertising
 

Newsgroups
 


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