ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP ListBox Save Data to Hidden Sheet, and ReLoad It upon opening (https://www.excelbanter.com/excel-programming/391487-help-listbox-save-data-hidden-sheet-reload-upon-opening.html)

[email protected]

HELP ListBox Save Data to Hidden Sheet, and ReLoad It upon opening
 
My experience with VB in Excel is limited so if some can help me
finish my final project that will be great.

I have a userform with a listbox, that I can add and delete records
from the listbox during each session while the form is open once I
close the form I loose my listbox values. I would like to load this
data upon closing the form ie when the form closes that data in the
list box will be sent to a page to be reloaded when the form is
reopened. Can some one show me the code for this. Thank you Nate

My form name is = frmServall
My Sheet name is = Sheet3 (where I want to save to and load from)
My listbox name is = Listbox1

if you need to see the file email me at and I will
send it to you. Thanks Again.


drhalter

HELP ListBox Save Data to Hidden Sheet, and ReLoad It upon opening
 
you need to start out with your initial data set in Sheet3, listed from A1
down.

in the userform initialize sub:
dim myrange as range

with sheets("Sheet3")
Set myrange = .Range(.Range("A1"), .Range("A1").End(xlDown))
end with

For Each c In myrange
Listbox1.AddItem c
Next c

then, before your form closes or unloads:

Sheets("Sheet3").Range(Sheets("Sheet3").Range("A1" ),
_Sheets("Sheet3").Range("A1").End(xlDown)).Delete

For x = 1 To Listbox1.ListCount
Sheets("Sheet3").Cells(x,1) = Listbox1.List(x - 1, 0)
Next x



" wrote:

My experience with VB in Excel is limited so if some can help me
finish my final project that will be great.

I have a userform with a listbox, that I can add and delete records
from the listbox during each session while the form is open once I
close the form I loose my listbox values. I would like to load this
data upon closing the form ie when the form closes that data in the
list box will be sent to a page to be reloaded when the form is
reopened. Can some one show me the code for this. Thank you Nate

My form name is = frmServall
My Sheet name is = Sheet3 (where I want to save to and load from)
My listbox name is = Listbox1

if you need to see the file email me at and I will
send it to you. Thanks Again.



Tom Ogilvy

HELP ListBox Save Data to Hidden Sheet, and ReLoad It upon opening
 
to write the list - in the terminate event:
for i = 0 to listbox1.Listcount - 1
worksheets("Sheet3").cells(i+1,1) = listbox1.list(i)
Next

to load the list - in the initialize event:


Dim rng as Range
with worksheets("Sheet3")
set rng = .range(.cells(1,1),.cells(1,1).end(xldown))
End with
Listbox1.List = rng.value

--
Regards,
Tom Ogilvy

" wrote:

My experience with VB in Excel is limited so if some can help me
finish my final project that will be great.

I have a userform with a listbox, that I can add and delete records
from the listbox during each session while the form is open once I
close the form I loose my listbox values. I would like to load this
data upon closing the form ie when the form closes that data in the
list box will be sent to a page to be reloaded when the form is
reopened. Can some one show me the code for this. Thank you Nate

My form name is = frmServall
My Sheet name is = Sheet3 (where I want to save to and load from)
My listbox name is = Listbox1

if you need to see the file email me at and I will
send it to you. Thanks Again.




All times are GMT +1. The time now is 03:46 AM.

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