Hello,
I'm trying to move to class modules and start doing more OO programing. I'm missing something big here on my first try. I thought I would make a simple class called list with a method that looked for a some data in a spreadsheet and who's attributes included the first and last row of the data.
Here is my class:
************************************************************
Option Explicit
Dim name As String
Dim header As String
Dim workbook As String
Dim spreadsheet As String
Dim counterstart As String
Dim counterend As String
Public Sub create(vHeader As Variant, sWorkbook As String, sSpreadsheet As String)
'for now the spreadsheet that contains the list needs to be open
'no spaces after the header row
Dim iHeaderRow As Integer
Dim iHeaderColumn As Integer
Dim iEndRow As Integer
Workbooks(sWorkbook).Sheets(sSpreadsheet).Activate
Workbooks(sWorkbook).Sheets(sSpreadsheet).Select
Cells.Find(What:=vHeader, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
iHeaderRow = Selection.Row
iHeaderColumn = Selection.Column
iEndRow = LastUsedRowInColumn(iHeaderColumn)
header = vHeader
workbook = sWorkbook
spreadsheet = sSpreadsheet
counterstart = iHeaderRow
counterend = iEndRow
End Sub
**********************************************************
Here is the code in a module trying to create an object:
***********************************************************
Sub testsub()
Dim testlist As List
Set testlist = New List
testlist.create("lookforthisword", "MasterSheet.xls", "Functions")
End Sub
**********************************************************
The error I'm getting is it says "compile error = expected" when I type the code and when I compile the code I get a "compile error, syntax error"
I'm sure its a basic concept I'm missing here, I'm just starting to get my feet wet with this OO stuff.
Would somebody throw me a bone?
Thanks,
Austin
I'm trying to move to class modules and start doing more OO programing. I'm missing something big here on my first try. I thought I would make a simple class called list with a method that looked for a some data in a spreadsheet and who's attributes included the first and last row of the data.
Here is my class:
************************************************************
Option Explicit
Dim name As String
Dim header As String
Dim workbook As String
Dim spreadsheet As String
Dim counterstart As String
Dim counterend As String
Public Sub create(vHeader As Variant, sWorkbook As String, sSpreadsheet As String)
'for now the spreadsheet that contains the list needs to be open
'no spaces after the header row
Dim iHeaderRow As Integer
Dim iHeaderColumn As Integer
Dim iEndRow As Integer
Workbooks(sWorkbook).Sheets(sSpreadsheet).Activate
Workbooks(sWorkbook).Sheets(sSpreadsheet).Select
Cells.Find(What:=vHeader, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
iHeaderRow = Selection.Row
iHeaderColumn = Selection.Column
iEndRow = LastUsedRowInColumn(iHeaderColumn)
header = vHeader
workbook = sWorkbook
spreadsheet = sSpreadsheet
counterstart = iHeaderRow
counterend = iEndRow
End Sub
**********************************************************
Here is the code in a module trying to create an object:
***********************************************************
Sub testsub()
Dim testlist As List
Set testlist = New List
testlist.create("lookforthisword", "MasterSheet.xls", "Functions")
End Sub
**********************************************************
The error I'm getting is it says "compile error = expected" when I type the code and when I compile the code I get a "compile error, syntax error"
I'm sure its a basic concept I'm missing here, I'm just starting to get my feet wet with this OO stuff.
Would somebody throw me a bone?
Thanks,
Austin