ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combobox list of sheet2 (https://www.excelbanter.com/excel-programming/428476-combobox-list-sheet2.html)

tkraju via OfficeKB.com

combobox list of sheet2
 
this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row
myList = Range(Cells(3, 8), Cells(LastRow, 14)).Address
what change is to be done to the above code if I want "sheet2 " list with
same parameters of above code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1


joel

combobox list of sheet2
 
Use Address with external = true. this gives the workbook as well so I added
code to remove the workbook.

LastRow = Range("H3").End(xlDown).Row
MyList = Range(Cells(3, 8), Cells(LastRow, 14)).Address(external:=True)
'remove workbook
MyList = Mid(MyList, InStr(MyList, "]") + 1)

"tkraju via OfficeKB.com" wrote:

this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row
myList = Range(Cells(3, 8), Cells(LastRow, 14)).Address
what change is to be done to the above code if I want "sheet2 " list with
same parameters of above code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1



Patrick Molloy

combobox list of sheet2
 
with worksheets("sheet2")
LastRow = .Range("H3").End(xlDown).Row
myList = .Range(.Cells(3, 8), .Cells(LastRow, 14)).Address
end with

fyi
this is the same as

LastRow = worksheets("sheet2").Range("H3").End(xlDown).Row
myList = worksheets("sheet2").Range(.Cells(3, 8),
worksheets("sheet2").Cells(LastRow, 14)).Address

but from a code perspective, its much cleaner IMHO
:)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:960f49ff0daf2@uwe...
this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row
myList = Range(Cells(3, 8), Cells(LastRow, 14)).Address
what change is to be done to the above code if I want "sheet2 " list
with
same parameters of above code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1


Dave Peterson

combobox list of sheet2
 
Dim myList as string
Dim LastRow as string

With worksheets("Sheet2")
lastrow = .range("H3").end(xldown).row
mylist = .range("H3:H" & lastrow).address(external:=true)
end with

I'd leave the workbook name, worksheet name, and address in that string. It
won't ever hurt and without it, you may have trouble.


"tkraju via OfficeKB.com" wrote:

this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row
myList = Range(Cells(3, 8), Cells(LastRow, 14)).Address
what change is to be done to the above code if I want "sheet2 " list with
same parameters of above code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1


--

Dave Peterson

tkraju via OfficeKB.com

combobox list of sheet2
 
Thank you,joel.its great,worked perfectly.

joel wrote:
Use Address with external = true. this gives the workbook as well so I added
code to remove the workbook.

LastRow = Range("H3").End(xlDown).Row
MyList = Range(Cells(3, 8), Cells(LastRow, 14)).Address(external:=True)
'remove workbook
MyList = Mid(MyList, InStr(MyList, "]") + 1)

this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row
myList = Range(Cells(3, 8), Cells(LastRow, 14)).Address
what change is to be done to the above code if I want "sheet2 " list with
same parameters of above code.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1


tkraju via OfficeKB.com

combobox list of sheet2
 
Thank you Dave.perfectly worked.

Dave Peterson wrote:
Dim myList as string
Dim LastRow as string

With worksheets("Sheet2")
lastrow = .range("H3").end(xldown).row
mylist = .range("H3:H" & lastrow).address(external:=true)
end with

I'd leave the workbook name, worksheet name, and address in that string. It
won't ever hurt and without it, you may have trouble.

this code is giving active sheet list.
LastRow = Range("H3").End(xlDown).Row

[quoted text clipped - 5 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1



All times are GMT +1. The time now is 04:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com