Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms
I have copied this VB from another answer to a similar problem I have. This
being part of it:- ------------------------------------ Private Sub LoadMarkets() Dim markets As New Scripting.Dictionary Dim index As Long Dim market As String For index = 2 To Source.Rows.Count market = Source.Cells(index, 1) If Not markets.Exists(market) Then markets.Add market, market cmbMarket.AddItem market End If Next End Sub -------------------------------- Obviously the spreadsheet works fine when I download it. But when I try to recreate the code into a different workbook it doesnt work. The problem being the second line of code. Dim markets As New.Scripting Dictionary. Problem being 'Used-defined type not defined'. Can someone please help me with this? Why it works in existing spreadsheet but then why if copied to a new workbook no longer works? Thanks Matthew |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms
Matthew Balch wrote: Dim markets As New Scripting.Dictionary The problem being the second line of code. Dim markets As New.Scripting Dictionary. Problem being 'Used-defined type not defined'. user defined types are not passed along in the code - i believe they are in the workbook itself. try searching the newsgroup for "user defined types" to learn more about them & maybe you will find a way to change it. i haven't used user defined types yet - i stick with "range", "string", "integer", etc. susan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms
I couldn't work out whty it wouldn't work or how to get round this.
In the end I kept the example workbooK i found with the relevant code I needed and copied everything from my template across and now it works. Completely befuddles me how some things can be workbook specific yet to me there is no clue how it is invariably linked to that workbook. "Matthew Balch" wrote: I have copied this VB from another answer to a similar problem I have. This being part of it:- ------------------------------------ Private Sub LoadMarkets() Dim markets As New Scripting.Dictionary Dim index As Long Dim market As String For index = 2 To Source.Rows.Count market = Source.Cells(index, 1) If Not markets.Exists(market) Then markets.Add market, market cmbMarket.AddItem market End If Next End Sub -------------------------------- Obviously the spreadsheet works fine when I download it. But when I try to recreate the code into a different workbook it doesnt work. The problem being the second line of code. Dim markets As New.Scripting Dictionary. Problem being 'Used-defined type not defined'. Can someone please help me with this? Why it works in existing spreadsheet but then why if copied to a new workbook no longer works? Thanks Matthew |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms
Matthew,
Each workbook using the code will need a reference set to the "Microsoft Scripting Runtime" library (scrrun.dll). In the VBE go to Tools | References and search for it in the listing displayed. Checkmark it and you should be all set. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "Matthew Balch" wrote in message I couldn't work out whty it wouldn't work or how to get round this. In the end I kept the example workbooK i found with the relevant code I needed and copied everything from my template across and now it works. Completely befuddles me how some things can be workbook specific yet to me there is no clue how it is invariably linked to that workbook. "Matthew Balch" wrote: I have copied this VB from another answer to a similar problem I have. This being part of it:- ------------------------------------ Private Sub LoadMarkets() Dim markets As New Scripting.Dictionary Dim index As Long Dim market As String For index = 2 To Source.Rows.Count market = Source.Cells(index, 1) If Not markets.Exists(market) Then markets.Add market, market cmbMarket.AddItem market End If Next End Sub -------------------------------- Obviously the spreadsheet works fine when I download it. But when I try to recreate the code into a different workbook it doesnt work. The problem being the second line of code. Dim markets As New.Scripting Dictionary. Problem being 'Used-defined type not defined'. Can someone please help me with this? Why it works in existing spreadsheet but then why if copied to a new workbook no longer works? Thanks Matthew |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Forms
Many Thanks Jim
"Jim Cone" wrote: Matthew, Each workbook using the code will need a reference set to the "Microsoft Scripting Runtime" library (scrrun.dll). In the VBE go to Tools | References and search for it in the listing displayed. Checkmark it and you should be all set. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "Matthew Balch" wrote in message I couldn't work out whty it wouldn't work or how to get round this. In the end I kept the example workbooK i found with the relevant code I needed and copied everything from my template across and now it works. Completely befuddles me how some things can be workbook specific yet to me there is no clue how it is invariably linked to that workbook. "Matthew Balch" wrote: I have copied this VB from another answer to a similar problem I have. This being part of it:- ------------------------------------ Private Sub LoadMarkets() Dim markets As New Scripting.Dictionary Dim index As Long Dim market As String For index = 2 To Source.Rows.Count market = Source.Cells(index, 1) If Not markets.Exists(market) Then markets.Add market, market cmbMarket.AddItem market End If Next End Sub -------------------------------- Obviously the spreadsheet works fine when I download it. But when I try to recreate the code into a different workbook it doesnt work. The problem being the second line of code. Dim markets As New.Scripting Dictionary. Problem being 'Used-defined type not defined'. Can someone please help me with this? Why it works in existing spreadsheet but then why if copied to a new workbook no longer works? Thanks Matthew |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
user forms | Excel Discussion (Misc queries) | |||
User Forms | Excel Discussion (Misc queries) | |||
User Forms | Excel Programming | |||
User forms | Excel Programming | |||
User forms | Excel Programming |