load workbook data to UserForm
I would like to load data to UserForm. I wrote the code, but I do not know where is the mistake.
Please help
VB Code:
Sub Show_HK()
UserForm2.KeepScrollBarsVisible = fmScrollBarsNone
UserForm2.ScrollBars = fmScrollBarsVertical
UserForm2.Spreadsheet1.Toolbar.Appearance = cc3D
Dim i As Long, j As Long, k As Long
k = Worksheets("$").range("D3").Value
For i = 1 To k
For j = 1 To 12
UserForm2.Spreadsheet1.Cells(i, j).Value = Workbooks("C:\Documents and Settings\bolcskei\Dokumenty\FA\TV\HKA 2004 1.0.xls").Worksheet("HK2").Cells(i, j).Value
Next j
Next i
UserForm2.Show (vbModeless)
End Sub
Re: load workbook data to UserForm
What is the error? Just a comment, but whygo to all the trouble of creating an
Excel userform with the entire spreadsheet contents? Why not just use Excel as is for this?
Re: load workbook data to UserForm
Quote:
Originally Posted by RobDog888
What is the error? Just a comment, but whygo to all the trouble of creating an
Excel userform with the entire spreadsheet contents? Why not just use Excel as is for this?
When I run the macro error 9 I receive. When I am working with some data on the sheet somethimes I would like to see another datas which are not present on the activated sheet, but I do not want to open and close some other excel files. For example when I am working with Balance Sheet of the company I would like to check datas from the Main book. My aim to load data the using UserForm could be more confortable to use.
Re: load workbook data to UserForm
I would have to think that the subscript out of range error is from this line
of code because the dollar sign is a reserved character in Excel. It thinks
there should be a value after it. Try changing the sheet name to something
else.
VB Code:
k = Worksheets("$").range("D3").Value
Re: load workbook data to UserForm
Quote:
Originally Posted by RobDog888
I would have to think that the subscript out of range error is from this line
of code because the dollar sign is a reserved character in Excel. It thinks
there should be a value after it. Try changing the sheet name to something
else.
VB Code:
k = Worksheets("$").range("D3").Value
No. I have problem with this:
VB Code:
UserForm2.Spreadsheet1.Cells(i, j).Value = Workbooks("C:\Documents and Settings\bolcskei\Dokumenty\FA\TV\HKA 2004 1.0.xls").Worksheet("HK2").Cells(i, j).Value