User-Defined Data Type

bradley7

Board Regular
Joined
Feb 22, 2005
Messages
102
Hi

I'm defining a data type

Type JobInfo
JobId As String
JobCustId As String
JobCustName As String
JobBusName As String
JobShortDesc1 As String
JobLongDesc1 As String * 400
JobAccType1 As String
JobNoOfItem1 As Integer
JobItemPrice1 As Integer
JobShortDesc2 As String
JobLongDesc2 As String * 400
JobAccType2 As String
JobNoOfItem2 As Integer
JobItemPrice2 As Integer
JobShortDesc3 As String
JobLongDesc3 As String * 400
JobAccType3 As String
JobNoOfItem3 As Integer
JobItemPrice3 As Integer
JobShortDesc4 As String
JobLongDesc4 As String * 400
JobAccType4 As String
JobNoOfItem4 As Integer
JobItemPrice4 As Integer
JobShortDesc5 As String
JobLongDesc5 As String * 400
JobAccType5 As String
JobNoOfItem5 As Integer
JobItemPrice5 As Integer
End Type

is there a better way to do this with an arraY?

EG
Type JobInfo
JobId As String
JobCustId As String
JobCustName As String
JobBusName As String
JobMoreInfo 5 time
JobShortDesc As String
JobLongDesc As String * 400
JobAccType As String
JobNoOfItem As Integer
JobItemPrice As Integer
end type
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could create another type for the repeated info and then use an array of that type in the main type.
 
Upvote 0
Code:
type JobData
JobShortDesc As String
JobLongDesc As String * 400
JobAccType As String
JobNoOfItem As Integer
JobItemPrice As Integer
End type
And:
Code:
Type JobInfo
JobId As String
JobCustId As String
JobCustName As String
JobBusName As String
JobMoreInfo(4) as JobData
end type
 
Last edited:
Upvote 0
ok, i understrand jobs(1).customer but how do you refer to the 4 sub fields.
i was thinking jobs(1,1).JobShortDesc but that didn't work.
what about jobs(1).jobsmoreInfo(1).JobShortDesc ?

Is that right?
 
Upvote 0
Yes (though it's JobMoreInfo rather than JobsMoreInfo)
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top