Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Object Creation

I am working on a VB macro that takes spreadsheet from a third party vendor
and grabs the headers for each column. It then allows to the user of the form
to line up these incoming headers adjacent to my preset ones in two side by
side list boxes. Based on which Preset Header the incoming ones are next to,
I want to apply specific formatting to these incoming data ranges.

I was thiking the best way to do this would be to create an object for each
Column that would have the three following properties:

Header Text
ColumnLetter (Which physical column it is on the sheet)
FormatType (Which of my predefined formats it should use after I have sorted
the incoming spreadsheet headers)

Questions:

How do I create the objects if this is the easiest way to solve my problem?
How do I create these properties inside of the objects?
How do I create my own custom formatting?

PLEASE HELP!!!! Thank you!!!

Nate
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Object Creation

Nate,
You could format a cell in a hidden column/worksheet for each format style
you have. Then you just apply (copy/pastespecial format) .

As for creating objects in Excel, you can use a Class module, then create an
array of your objects.(or possibly with a Collection).

<cHeaderFormat
Option Explicit

Dim mHeaderText As String
Dim ColumnDestination As String
Dim FormatSource As Range

Public Property Let HeaderText(argIn As String)
mHeaderText = argIn
End Property

Public Property Get HeaderText() As String
HeaderText = mHeaderText
End Property

Public Property Let ColumnDestination(argIn As String)
mColumnDestination = argIn
End Property

Public Property Get ColumnDestination() As String
ColumnDestination = mColumnDestination
End Property

Public Property Let FormatSource(argIn As Range)
If argIn.Cells.Count 1 Then
MsgBox "Only single cell allowed"
Exit Property
End If

Set mFormatSource = argIn
End Property

Public Property Get FormatSource() As Range
Set FormatSource = mFormatSource
End Property
</cHeaderFormat

And then using this class, create an array at the suitable time, maybe when
the userform loads, with 1 object for each item in you listbox

<UserForm
Dim objHeaders() As cHeaderFormat

Private Sub UserForm_Initialize()
Dim i As Long

With lstHeaders
ReDim objHeaders(.ListCount)
For i = 0 To .ListCount - 1
Set objHeaders(i) = New cHeaderFormat
objHeaders(i).HeaderText = .List(i)
Next
End With
End Sub
</UserForm

Adjust for your actual situation

NickHK

"Nate Lasko" wrote in message
...
I am working on a VB macro that takes spreadsheet from a third party

vendor
and grabs the headers for each column. It then allows to the user of the

form
to line up these incoming headers adjacent to my preset ones in two side

by
side list boxes. Based on which Preset Header the incoming ones are next t

o,
I want to apply specific formatting to these incoming data ranges.

I was thiking the best way to do this would be to create an object for

each
Column that would have the three following properties:

Header Text
ColumnLetter (Which physical column it is on the sheet)
FormatType (Which of my predefined formats it should use after I have

sorted
the incoming spreadsheet headers)

Questions:

How do I create the objects if this is the easiest way to solve my

problem?
How do I create these properties inside of the objects?
How do I create my own custom formatting?

PLEASE HELP!!!! Thank you!!!

Nate



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Option button object proeprties or object not found in vba Pete Straman S via OfficeKB.com Excel Programming 0 August 31st 05 05:49 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"