LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Compile Error: Method or Data Member not found

Hi,

I was trying to run some VBA code when the error message above came up...
Try as I might, i could not find what was wrong with it. Could someone please
help me?

There are 154 companies in Sheet2, which are then divided into 6 groups.
Each of these groups had a seperate sheet for their raw data. I had named the
six raw data ranges "Data1", "Data2", etc. I also have one seperate Dividend
sheet, which has the raw data of the dividends in it. This is what I had
wanted the code to do:

For each of the companies, go to the dividend page. For each dividend, find
out what the market price was on the payment date of the dividend. Then find
out what 1+dividend/price is, and then paste it into a seperate sheet,
"Sheet4".

For some reason, I just don't know why it doesn't work. My other macros on
the worksheet works fine, so it doesn't seem to be anything wrong with my
excel, so its probably my code. Could someone please help?

Code is below:

Option Explicit

Sub dividend()


Dim i As Integer
Dim j As Integer
Dim asx As String
Dim code As Integer
Dim position As Integer
Dim number As Integer
Dim reference As String
Dim paydate As Integer
Dim closingrow As Integer
Dim closingcolumn As Integer
Dim closingprice As Double
Dim dividend As Double
Dim divunit As Double
Dim divcolumn As Integer

For i = 1 To 154
asx = Sheet2.Cells(4 + i, 1).Value
code = Sheet2.Cells(4 + i, 2).Value
position = Sheet2.Cells(4 + i, 10).Value
number = Sheet2.Cells(4 + i, 11).Value
reference = "Data" & code
closingcolumn = Application.WorksheetFunction.Match(asx,
Application.WorksheetFunction.Index(Application.Wo rksheetFunction.indirect(reference), 1, 0), 0)

If i <= 76 Then
divcolumn = Application.WorksheetFunction.Match(asx,
Sheet4.Range("A1:EU1"))
Else
divcolumn = Application.WorksheetFunction.Match(asx,
Sheet4.Range("A20:EY20"))
End If

If number = 0 Then
Else
For j = 1 To number
dividend = Sheet3.Cells(position + 1 + j, 3).Value / 100
paydate = Sheet3.Cells(position + 1 + j, 7).Value
closingrow = Application.WorksheetFunction.Match(paydate,
Application.WorksheetFunction.Index(Application.Wo rksheetFunction.indirect(reference), 0, closingcolumn), 0)
closingprice =
Application.WorksheetFunction.Index(Application.Wo rksheetFunction.indirect(reference), closingrow, closingcolumn)
divunit = 1 + dividend / closingprice

If i <= 76 Then
Sheet4.Cells(1 + j, divcolumn).Value = paydate
Sheet4.Cells(1 + j, divcolumn + 1).Value = divunit
Else
Sheet4.Cells(20 + j, divcolumn).Value = paydate
Sheet4.Cells(20 + j, divcolumn + 1).Value = divunit
End If

Next j
End If
Next i

'
End Sub

 
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
Compile error: Method or data member not found Brian Day Excel Worksheet Functions 0 July 22nd 07 03:20 AM
Compile error: Method or data member not found OliverB Excel Programming 2 April 13th 07 10:48 AM
Compile Error Method or data member not found ExcelMonkey Excel Programming 1 October 4th 05 10:41 PM
Compile Error: Method or data member not found Nick S[_3_] Excel Programming 2 November 16th 04 02:38 PM
Compile Error: Method or data member not found Nick S[_2_] Excel Programming 1 November 16th 04 11:41 AM


All times are GMT +1. The time now is 02:27 PM.

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"