|
-
Jan 13th, 2005, 02:08 AM
#1
Thread Starter
Addicted Member
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
-
Jan 13th, 2005, 01:42 PM
#2
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 14th, 2005, 02:35 AM
#3
Thread Starter
Addicted Member
Re: load workbook data to UserForm
 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.
-
Jan 14th, 2005, 11:58 AM
#4
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2005, 01:10 AM
#5
Thread Starter
Addicted Member
Re: load workbook data to UserForm
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|