![]() |
Help with VBA Type statement
I am using Excel 2000, and I am attempting to build, what I consider an array
using the Type declariation. Public Type SIGDB SigName As String * 12 SigType As String * 15 Conflict As Integer Oppos As Integer Para As Integer OS As Integer AspectIndexClr As Integer AspectIndexStop As Integer AspectClrName As String * 20 AspectStopName As String * 15 AppBlk As String * 8 Side As String * 2 Direction As String * 2 End Type In a module I have: For i = 1 To NumSig ReDim Route(i) As SIGDB Route(i).SigName = Cells(cRow, 1) Route(i).SigType = Cells(cRow, 2) next i When I later attempt to access the data it's not there. Any ideas? Bob |
Help with VBA Type statement
The Redim statement will clear the contents of the array. Use the
Preserve keyword to preserve the contents of the array. E.g., ReDim Preserve Route(i) As SIGDB -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Rednosebob" wrote in message ... I am using Excel 2000, and I am attempting to build, what I consider an array using the Type declariation. Public Type SIGDB SigName As String * 12 SigType As String * 15 Conflict As Integer Oppos As Integer Para As Integer OS As Integer AspectIndexClr As Integer AspectIndexStop As Integer AspectClrName As String * 20 AspectStopName As String * 15 AppBlk As String * 8 Side As String * 2 Direction As String * 2 End Type In a module I have: For i = 1 To NumSig ReDim Route(i) As SIGDB Route(i).SigName = Cells(cRow, 1) Route(i).SigType = Cells(cRow, 2) next i When I later attempt to access the data it's not there. Any ideas? Bob |
Help with VBA Type statement
I get a compiler error: Variable not defined.
"Rednosebob" wrote: I am using Excel 2000, and I am attempting to build, what I consider an array using the Type declariation. Public Type SIGDB SigName As String * 12 SigType As String * 15 Conflict As Integer Oppos As Integer Para As Integer OS As Integer AspectIndexClr As Integer AspectIndexStop As Integer AspectClrName As String * 20 AspectStopName As String * 15 AppBlk As String * 8 Side As String * 2 Direction As String * 2 End Type In a module I have: For i = 1 To NumSig ReDim Route(i) As SIGDB Route(i).SigName = Cells(cRow, 1) Route(i).SigType = Cells(cRow, 2) next i When I later attempt to access the data it's not there. Any ideas? Bob |
Help with VBA Type statement
What line of code gives you the error? Have you actually declared
the variable? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Rednosebob" wrote in message ... I get a compiler error: Variable not defined. "Rednosebob" wrote: I am using Excel 2000, and I am attempting to build, what I consider an array using the Type declariation. Public Type SIGDB SigName As String * 12 SigType As String * 15 Conflict As Integer Oppos As Integer Para As Integer OS As Integer AspectIndexClr As Integer AspectIndexStop As Integer AspectClrName As String * 20 AspectStopName As String * 15 AppBlk As String * 8 Side As String * 2 Direction As String * 2 End Type In a module I have: For i = 1 To NumSig ReDim Route(i) As SIGDB Route(i).SigName = Cells(cRow, 1) Route(i).SigType = Cells(cRow, 2) next i When I later attempt to access the data it's not there. Any ideas? Bob |
Help with VBA Type statement
The "Public Type SIGDB" is defined in Declariations section of the program
and the compiler errors occurs in the Module code where I'm using the "ReDim Preserve Route(i) As SIGDB". Thanks! Bob "Chip Pearson" wrote: What line of code gives you the error? Have you actually declared the variable? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Rednosebob" wrote in message ... I get a compiler error: Variable not defined. "Rednosebob" wrote: I am using Excel 2000, and I am attempting to build, what I consider an array using the Type declariation. Public Type SIGDB SigName As String * 12 SigType As String * 15 Conflict As Integer Oppos As Integer Para As Integer OS As Integer AspectIndexClr As Integer AspectIndexStop As Integer AspectClrName As String * 20 AspectStopName As String * 15 AppBlk As String * 8 Side As String * 2 Direction As String * 2 End Type In a module I have: For i = 1 To NumSig ReDim Route(i) As SIGDB Route(i).SigName = Cells(cRow, 1) Route(i).SigType = Cells(cRow, 2) next i When I later attempt to access the data it's not there. Any ideas? Bob |
All times are GMT +1. The time now is 05:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com